Beispiel #1
0
        /// <summary>
        /// Get the size guide for the product
        /// </summary>
        /// <param name="currentContent"></param>
        /// <returns></returns>
        protected int GetSizeGuide(FashionProductContent currentContent)
        {
            int output = UrlHelpers.GetReferenceFromUrl(currentContent.SizeGuide);

            if (output > 0)
            {
                return(output);
            }

            var ancestors = ContentLoader.GetAncestors(currentContent.ContentLink);

            foreach (var ancestor in ancestors)
            {
                var content = ContentLoader.Get <IContent>(ancestor.ContentLink);
                if (content is FashionStoreSubLandingNodeContent)
                {
                    output = UrlHelpers.GetReferenceFromUrl(((FashionStoreSubLandingNodeContent)content).SizeGuide);
                }
                else if (content is FashionStoreLandingNodeContent)
                {
                    output = UrlHelpers.GetReferenceFromUrl(((FashionStoreLandingNodeContent)content).SizeGuide);
                }
                if (output > 0)
                {
                    return(output);
                }
            }
            return(-1);
        }
        private string GetDefaultImage(FashionProductContent productContent, UrlResolver urlResolver, IPermanentLinkMapper permanentLinkMapper)
        {
            var commerceMedia = productContent.CommerceMediaCollection.OrderBy(m => m.SortOrder).FirstOrDefault(z => z.GroupName != null && z.GroupName.ToLower() != "swatch");

            if (commerceMedia != null)
            {
                var contentReference = commerceMedia.AssetContentLink(permanentLinkMapper);
                return(urlResolver.GetUrl(contentReference));
            }
            return(NoImagePath);
        }
Beispiel #3
0
        /// <summary>
        /// Note! This method should not fail, it will prevent the product from
        /// being saved.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void events_PublishedContent(object sender, ContentEventArgs e)
        {
            if (IndexingEnabled == false)
            {
                return;
            }

            FindHelper helper = ServiceLocator.Current.GetInstance <FindHelper>();

            if (e.Content is IIndexableContent)
            {
                try
                {
                    IndexProduct(helper, e.Content as IIndexableContent);
                }
                catch (Exception exception)
                {
                    _log.Error("Cannot index: " + e.ContentLink.ToString(), exception);
                }
            }
            else if (e.Content is FashionItemContent)
            {
                EntryContentBase parent = GetParent(e.Content as EntryContentBase);

                FashionProductContent productContent = parent as FashionProductContent;
                if (productContent != null)
                {
                    try
                    {
                        IndexProduct(helper, productContent);
                    }
                    catch (Exception exception)
                    {
                        _log.Error("Cannot index: " + e.ContentLink.ToString(), exception);
                    }
                }
            }
        }
        /// <summary>
        /// Note! This method should not fail, it will prevent the product from
        /// being saved.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void PublishedContent(object sender, ContentEventArgs e)
        {
            if (IndexingEnabled == false)
            {
                return;
            }


            if (e.Content is IIndexableContent)
            {
                try
                {
                    IndexProduct(e.Content as IIndexableContent);
                }
                catch (Exception exception)
                {
                    _log.Error("Cannot index: " + e.ContentLink.ToString(), exception);
                }
            }
            else if (e.Content is FashionItemContent)
            {
                EntryContentBase parent = GetParent(e.Content as EntryContentBase);

                FashionProductContent productContent = parent as FashionProductContent;
                if (productContent != null)
                {
                    try
                    {
                        IndexProduct(productContent);
                    }
                    catch (Exception exception)
                    {
                        _log.Error("Cannot index: " + e.ContentLink.ToString(), exception);
                    }
                }
            }
        }
Beispiel #5
0
 public ProductViewModel(FashionProductContent product)
 {
     this._product = product;
 }