/// <summary>
        /// Gets the product 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="productId">The product identifier.</param>
        /// <param name="includeVariants">if set to <c>true</c> [include variants].</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 <GetProductPricesResult, IDictionary <string, Price> > GetProductPrices([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext, string catalogName, string productId, bool includeVariants, params string[] priceTypeIds)
        {
            Assert.ArgumentNotNull(storefront, "storefront");

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

            var request = new Sitecore.Commerce.Engine.Connect.Services.Prices.GetProductPricesRequest(catalogName, productId, priceTypeIds)
            {
                DateTime = this.GetCurrentDate()
            };

            if (Sitecore.Context.User.IsAuthenticated)
            {
                request.UserId = visitorContext.GetCustomerId();
            }

            request.IncludeVariantPrices = includeVariants;
            request.CurrencyCode         = StorefrontManager.GetCustomerCurrency();
            var result = this.PricingServiceProvider.GetProductPrices(request);

            Helpers.LogSystemMessages(result.SystemMessages, result);
            return(new ManagerResponse <GetProductPricesResult, IDictionary <string, Price> >(result, result.Prices ?? new Dictionary <string, Price>()));
        }
        public ManagerResponse <GetProductPricesResult, IDictionary <string, Price> > GetProductPrices(string catalogName, string productId, bool includeVariants, params string[] priceTypeIds)
        {
            if (priceTypeIds == null)
            {
                priceTypeIds = PricingManager.DefaultPriceTypeIds;
            }

            var pricesRequest =
                new Sitecore.Commerce.Engine.Connect.Services.Prices.GetProductPricesRequest(catalogName, productId, priceTypeIds)
            {
                DateTime             = DateTime.UtcNow,
                IncludeVariantPrices = includeVariants
            };

            GetProductPricesResult serviceProviderResult = this.pricingServiceProvider.GetProductPrices(pricesRequest);

            return(new ManagerResponse <GetProductPricesResult, IDictionary <string, Price> >(serviceProviderResult, serviceProviderResult.Prices ?? new Dictionary <string, Price>()));
        }
示例#3
0
        public GetProductPricesResult GetProductPrices(
            string catalogName,
            string productId,
            bool includeVariants,
            params string[] priceTypeIds)
        {
            Assert.ArgumentNotNullOrEmpty(catalogName, nameof(catalogName));
            Assert.ArgumentNotNullOrEmpty(productId, nameof(productId));
            Assert.ArgumentNotNull(priceTypeIds, nameof(priceTypeIds));

            var pricesRequest = new GetProductPricesRequest(catalogName, productId, priceTypeIds)
            {
                DateTime             = DateTime.UtcNow,
                IncludeVariantPrices = includeVariants
            };

            return(this.Execute(pricesRequest, this.pricingServiceProvider.GetProductPrices));
        }
示例#4
0
        public ManagerResponse <GetProductPricesResult, IDictionary <string, Price> > GetProductPrices(string catalogName, string productId, bool includeVariants, string userId, params string[] priceTypeIds)
        {
            if (priceTypeIds == null)
            {
                priceTypeIds = _defaultPriceTypeIds;
            }

            var request = new GetProductPricesRequest(catalogName, productId, priceTypeIds)
            {
                DateTime = GetCurrentDate()
            };

            request.UserId = userId;
            request.IncludeVariantPrices = includeVariants;
            request.CurrencyCode         = CurrencyManager.CurrencyContext.CurrencyCode;
            var result = PricingServiceProvider.GetProductPrices(request);

            result.WriteToSitecoreLog();
            return(new ManagerResponse <GetProductPricesResult, IDictionary <string, Price> >(result, result.Prices ?? new Dictionary <string, Price>()));
        }