Exemplo n.º 1
0
        private ProductPageViewModel LoadProductModel(string slug)
        {
            CustomUrl customUrl;
            var       product = HccApp.ParseProductBySlug(slug, out customUrl);

            if (customUrl != null && !IsConcreteItemModule)
            {
                var redirectUrl = HccUrlBuilder.RouteHccUrl(HccRoute.Product, new { slug = customUrl.RedirectToUrl });
                if (customUrl.IsPermanentRedirect)
                {
                    Response.RedirectPermanent(redirectUrl);
                }
                else
                {
                    Response.Redirect(redirectUrl);
                }
            }
            if (product == null)
            {
                StoreExceptionHelper.ShowInfo(Localization.GetString("ProductNotFound"));
            }
            else if (product.Status != ProductStatus.Active)
            {
                StoreExceptionHelper.ShowInfo(Localization.GetString("ProductNotActive"));
            }
            else if (!HccApp.CatalogServices.TestProductAccess(product))
            {
                StoreExceptionHelper.ShowInfo(Localization.GetString("ProductNotEnoughPermission"));
            }

            var model = new ProductPageViewModel {
                LocalProduct = product
            };

            LoadImageUrls(model);
            model.Prices = CreateProductPrices(product);
            LoadRelatedItems(model);
            LoadBundledItems(model);
            model.IsAvailableForWishList = SessionManager.IsUserAuthenticated(HccApp);
            model.AllowReviews           = product.AllowReviews.HasValue
                ? product.AllowReviews.Value
                : HccApp.CurrentStore.Settings.AllowProductReviews;
            LoadAlternateImages(model);
            model.PreRenderedTypeValues = product.RenderTypeProperties();
            model.SwatchHtml            = ImageHelper.GenerateSwatchHtmlForProduct(product, HccApp);
            model.LineItemId            = Request.QueryString["LineItemId"].ConvertToNullable <long>();

            // make the minimum quantity be the new default if necessary, otherwise use the actual default (1)
            if (product.MinimumQty > 0)
            {
                model.Quantity = product.MinimumQty;
            }

            LoadGiftCardAmounts(model);

            return(model);
        }
Exemplo n.º 2
0
        private string LookupProduct(string slugText)
        {
            var productText = string.Empty;

            if (!string.IsNullOrEmpty(slugText))
            {
                CustomUrl customUrl;
                var       product = HccApp.ParseProductBySlug(slugText, out customUrl);

                if (product != null)
                {
                    productText = product.ProductName;
                }
            }
            return(productText);
        }