Exemplo n.º 1
0
        public void GetProductBulkPrices(IEnumerable <ICatalogProduct> catalogProducts)
        {
            var catalogProductsArray = catalogProducts as ICatalogProduct[] ?? catalogProducts?.ToArray();

            if (catalogProductsArray == null || !catalogProductsArray.Any())
            {
                return;
            }

            var catalogName = catalogProductsArray.Select(p => p.CatalogName).First();
            var productIds  = catalogProductsArray.Select(p => p.ProductId).ToList();

            var pricesResponse = PricingManager.GetProductBulkPrices(catalogName, productIds, null);
            var prices         = pricesResponse?.Result ?? new Dictionary <string, Price>();

            foreach (var product in catalogProductsArray)
            {
                Price price;
                if (!prices.Any() || !prices.TryGetValue(product.ProductId, out price))
                {
                    continue;
                }

                var extendedPrice = (ExtendedCommercePrice)price;

                product.ListPrice     = extendedPrice.Amount;
                product.AdjustedPrice = extendedPrice.ListPrice;

                product.LowestPricedVariantAdjustedPrice  = extendedPrice.LowestPricedVariant;
                product.LowestPricedVariantListPrice      = extendedPrice.LowestPricedVariantListPrice;
                product.HighestPricedVariantAdjustedPrice = extendedPrice.HighestPricedVariant;
            }
        }
Exemplo n.º 2
0
 public CatalogManager(CatalogServiceProvider catalogServiceProvider, GlobalizationServiceProvider globalizationServiceProvider, PricingManager pricingManager, InventoryManager inventoryManager, CatalogItemContext catalogItemContext, ICommerceSearchManager commerceSearchManager, StorefrontContext storefrontContext)
 {
     CatalogServiceProvider       = catalogServiceProvider;
     GlobalizationServiceProvider = globalizationServiceProvider;
     PricingManager        = pricingManager;
     InventoryManager      = inventoryManager;
     CatalogItemContext    = catalogItemContext;
     CommerceSearchManager = commerceSearchManager;
     StorefrontContext     = storefrontContext;
 }
Exemplo n.º 3
0
        public void GetProductPrice(ICatalogProduct productViewModel)
        {
            if (productViewModel == null)
            {
                return;
            }

            var includeVariants = productViewModel.Variants != null && productViewModel.Variants.Any();
            var pricesResponse  = PricingManager.GetProductPrices(productViewModel.CatalogName, productViewModel.ProductId, includeVariants, null);

            if (pricesResponse == null || !pricesResponse.ServiceProviderResult.Success || pricesResponse.Result == null)
            {
                return;
            }

            Price price;

            if (pricesResponse.Result.TryGetValue(productViewModel.ProductId, out price))
            {
                var extendedPrice = (ExtendedCommercePrice)price;
                productViewModel.ListPrice     = price.Amount;
                productViewModel.AdjustedPrice = extendedPrice.ListPrice;
            }

            if (!includeVariants)
            {
                return;
            }

            foreach (var variant in productViewModel.Variants)
            {
                if (!pricesResponse.Result.TryGetValue(variant.VariantId, out price))
                {
                    continue;
                }

                var extendedPrice = (ExtendedCommercePrice)price;
                variant.ListPrice     = extendedPrice.Amount;
                variant.AdjustedPrice = extendedPrice.ListPrice;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WishListManager" /> class.
        /// </summary>
        /// <param name="wishListServiceProvider">The wish list service provider.</param>
        /// <param name="accountManager">The account manager.</param>
        /// <param name="inventoryManager">The inventory manager.</param>
        /// <param name="pricingManager">The pricing manager.</param>
        public WishListManager([NotNull] WishListServiceProvider wishListServiceProvider, [NotNull] AccountManager accountManager, [NotNull] InventoryManager inventoryManager, [NotNull] PricingManager pricingManager)
        {
            Assert.ArgumentNotNull(wishListServiceProvider, "wishListServiceProvider");
            Assert.ArgumentNotNull(accountManager, "accountManager");
            Assert.ArgumentNotNull(inventoryManager, "inventoryManager");
            Assert.ArgumentNotNull(pricingManager, "pricingManager");

            this.WishListServiceProvider = wishListServiceProvider;
            this.AccountManager          = accountManager;
            this.InventoryManager        = inventoryManager;
            this.PricingManager          = pricingManager;
        }