/// <summary> /// Return a new GetPromotionDetailsRequest, populating the known basket attributes. Note custom attributes are supported in the request too. /// </summary> /// <param name="companyKey"></param> /// <returns></returns> public static PromotionDetailsByProductRequest GetPromotionDetailsByProductRequest(string companyKey) { var promotionsByProductRequest = new PromotionDetailsByProductRequest() { // Required items ValidationDate = DateTime.UtcNow, CompanyKey = companyKey, // Indicate that we want to ignore the time part of the [ValidationDate] specified above, // so the repsonse should include all promotions for the day. ValidateForTime = false, // Standard basket attributes. These are optional and when specified // will impact which promotions are returned based on their defined Criteria. CustomerGroup = "NORMAL", Channel = "RETAIL", StoreGroup = "LONDON", Store = "KINGSTON" }; promotionsByProductRequest.AddProduct("EXAMPLE_IMPORTED_PRODUCT_1", string.Empty); return(promotionsByProductRequest); }
/// <summary> /// Build the export request for item level promos. Pass the products for this batch. /// </summary> /// <param name="batchProducts"></param> /// <param name="store"></param> /// <param name="savedProductMappings"></param> /// <returns></returns> private PromotionDetailsByProductRequest BuildExportProductPromotionsRequest(IEnumerable<Product> batchProducts, Dictionary<string, int> savedProductMappings) { // Build the request first... var itemPromoDetailsRequest = new PromotionDetailsByProductRequest() { ValidateForTime = false, // Looking for the whole day. CompanyKey = _promoSettings.CompanyKey, ValidationDate = DateTime.UtcNow.Date, Channel = _promoSettings.Channel, StoreGroup = _promoSettings.StoreGroup // Note: Can't pass the store at this point, because there might be multiple stores and the store defined in setttings relates to products to be synchronized. //Store = store }; batchProducts.ToList().ForEach(product => { var productMappings = _productMappingService.RetrieveAllVariantsByProductId(product.Id, EntityAttributeName.Product, false); productMappings.ToList().ForEach(productMapping => { itemPromoDetailsRequest.AddProduct(product.Id.ToString(), productMapping.VariantCode); savedProductMappings.Add(string.Format("<product>{0}</product><variant>{1}</variant>", product.Id.ToString(), productMapping.VariantCode), productMapping.Id); }); }); return itemPromoDetailsRequest; }
public PromotionDetailsByProductResponse ExportPromotionsForProducts(PromotionDetailsByProductRequest request) { PromotionDetailsByProductResponse exportResult = null; try { var exportService = _promoSettings.GetExportService(); exportResult = exportService.ExportPromotionsForProducts(request); } catch (Exception ex) { _logger.Error("Qixol Promos export promotions for products", ex); } return exportResult; }