Esempio n. 1
0
        public GetProductBulkPricesResult GetProductBulkPrices(
            string catalogName,
            IEnumerable <string> productIds,
            params string[] priceTypeIds)
        {
            Assert.ArgumentNotNullOrEmpty(catalogName, nameof(catalogName));
            Assert.ArgumentNotNull(productIds, nameof(productIds));
            Assert.ArgumentNotNull(priceTypeIds, nameof(priceTypeIds));

            var bulkPricesRequest = new GetProductBulkPricesRequest(catalogName, productIds, priceTypeIds)
            {
                DateTime = DateTime.UtcNow
            };

            return(this.Execute(bulkPricesRequest, this.pricingServiceProvider.GetProductBulkPrices));
        }
        public ManagerResponse <GetProductBulkPricesResult, IDictionary <string, Price> > GetProductBulkPrices(string catalogName, IEnumerable <string> productIds, params string[] priceTypeIds)
        {
            if (priceTypeIds == null)
            {
                priceTypeIds = PricingManager.DefaultPriceTypeIds;
            }

            var bulkPricesRequest = new Sitecore.Commerce.Engine.Connect.Services.Prices.GetProductBulkPricesRequest(catalogName, productIds, priceTypeIds)
            {
                DateTime = DateTime.UtcNow
            };

            GetProductBulkPricesResult  productBulkPrices = this.pricingServiceProvider.GetProductBulkPrices(bulkPricesRequest);
            IDictionary <string, Price> result            = productBulkPrices.Prices ?? new Dictionary <string, Price>();

            return(new ManagerResponse <GetProductBulkPricesResult, IDictionary <string, Price> >(productBulkPrices, result));
        }
        /// <summary>
        /// Gets the product bulk prices.
        /// </summary>
        /// <param name="storefront">The storefront.</param>
        /// <param name="visitorContext">The visitor context.</param>
        /// <param name="catalogName">Name of the catalog.</param>
        /// <param name="productIds">The product ids.</param>
        /// <param name="priceTypeIds">The price type ids.</param>
        /// <returns>The manager response with the list of prices in the Result.</returns>
        public virtual ManagerResponse <GetProductBulkPricesResult, IDictionary <string, Price> > GetProductBulkPrices([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext, string catalogName, IEnumerable <string> productIds, params string[] priceTypeIds)
        {
            Assert.ArgumentNotNull(storefront, "storefront");

            if (priceTypeIds == null)
            {
                priceTypeIds = DefaultPriceTypeIds;
            }

            var request = new Sitecore.Commerce.Engine.Connect.Services.Prices.GetProductBulkPricesRequest(catalogName, productIds, priceTypeIds)
            {
                CurrencyCode = StorefrontManager.GetCustomerCurrency(),
                DateTime     = this.GetCurrentDate()
            };

            var result = this.PricingServiceProvider.GetProductBulkPrices(request);

            // Currently, both Categories and Products are passed in and are waiting for a fix to filter the categories out. Until then, this code is commented
            // out as it generates an unecessary Error event indicating the product cannot be found.
            // Helpers.LogSystemMessages(result.SystemMessages, result);
            return(new ManagerResponse <GetProductBulkPricesResult, IDictionary <string, Price> >(result, result.Prices ?? new Dictionary <string, Price>()));
        }
Esempio n. 4
0
        public ManagerResponse <GetProductBulkPricesResult, IDictionary <string, Price> > GetProductBulkPrices(string catalogName, IEnumerable <string> productIds, params string[] priceTypeIds)
        {
            Assert.ArgumentNotNull(catalogName, nameof(catalogName));
            Assert.ArgumentNotNull(productIds, nameof(productIds));

            if (priceTypeIds == null)
            {
                priceTypeIds = _defaultPriceTypeIds;
            }

            var request = new GetProductBulkPricesRequest(catalogName, productIds, priceTypeIds)
            {
                CurrencyCode = CurrencyManager.CurrencyContext.CurrencyCode,
                DateTime     = GetCurrentDate()
            };

            var result = PricingServiceProvider.GetProductBulkPrices(request);

            // Currently, both Categories and Products are passed in and are waiting for a fix to filter the categories out. Until then, this code is commented
            // out as it generates an unecessary Error event indicating the product cannot be found.
            //result.WriteToSitecoreLog();
            return(new ManagerResponse <GetProductBulkPricesResult, IDictionary <string, Price> >(result, result.Prices ?? new Dictionary <string, Price>()));
        }