Images In RSS Feeds for use with MailChimp

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 anni tempo fa
Images are in the Blog's RSS.   They are not in the New Products RSS.
(Which RSS are you concerned with?)
12 anni tempo fa
I am concerned about New Products RSS.
12 anni tempo fa
It will require custom programming.  It should not be that hard to do.
Look at CatalogController.cs

        protected ProductDetailsModel PrepareProductDetailsPageModel(Product product)
        {
           ...

            //pictures
            model.DefaultPictureZoomEnabled = _mediaSettings.DefaultPictureZoomEnabled;
            var pictures = _pictureService.GetPicturesByProductId(product.Id);
            if (pictures.Count > 0)
            {
                //default picture
                model.DefaultPictureModel = new PictureModel()
                {
                    ImageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault(), _mediaSettings.ProductDetailsPictureSize),
                    FullSizeImageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault()),
                    Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
                    AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name),
                };
12 anni tempo fa
Not sure what you mean. where do I use this piece of code, I found this code in CatlogController.cs not sure what I need to do? appreciate if you could tell where i need to use this code to pull images in rss for new products..
12 anni tempo fa
CatalogController also contains
        public ActionResult RecentlyAddedProductsRss()

You would need to figure out how to modify  RecentlyAddedProductsRss(), to use above  ImageUrl = _pictureService.GetPictureUrl(...
12 anni tempo fa
I am not able to figure out how to pull image, it would be great if you could help me on this..
11 anni tempo fa
In CatalogController use this code (v3.00):


       public ActionResult RecentlyAddedProductsRss()
        {
            var feed = new SyndicationFeed(
                                    string.Format("{0}: Recently added products", _storeContext.CurrentStore.Name),
                                    "Information about products",
                                    new Uri(_webHelper.GetStoreLocation(false)),
                                    "RecentlyAddedProductsRSS",
                                    DateTime.UtcNow);

            if (!_catalogSettings.RecentlyAddedProductsEnabled)
                return new RssActionResult() { Feed = feed };

            var items = new List<SyndicationItem>();

            var products = _productService.SearchProducts(
                storeId: _storeContext.CurrentStore.Id,
                orderBy: ProductSortingEnum.CreatedOn,
                pageSize: _catalogSettings.RecentlyAddedProductsNumber);
            foreach (var product in products)
            {
                string productUrl = Url.RouteUrl("Product", new { SeName = product.GetSeName() }, "http");

                var item = new SyndicationItem(product.GetLocalized(x => x.Name), product.GetLocalized(x => x.ShortDescription), new Uri(productUrl), String.Format("RecentlyAddedProduct:{0}", product.Id), product.CreatedOnUtc);

                var pictures = _pictureService.GetPicturesByProductId(product.Id);
                if (pictures.Count > 0)
                {
                    var imageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault(), _mediaSettings.ProductDetailsPictureSize);
                    item.ElementExtensions.Add(
                        new XElement("enclosure", new XAttribute("type", "image/jpeg"), new XAttribute("url", imageUrl)).CreateReader()
                    );
                }

                items.Add(item);
            }
            feed.Items = items;
            return new RssActionResult() { Feed = feed };
        }
11 anni tempo fa
algorithmer wrote:
In CatalogController use this code (v3.00):


       public ActionResult RecentlyAddedProductsRss()
        {
            var feed = new SyndicationFeed(
                                    string.Format("{0}: Recently added products", _storeContext.CurrentStore.Name),
                                    "Information about products",
                                    new Uri(_webHelper.GetStoreLocation(false)),
                                    "RecentlyAddedProductsRSS",
                                    DateTime.UtcNow);

            if (!_catalogSettings.RecentlyAddedProductsEnabled)
                return new RssActionResult() { Feed = feed };

            var items = new List<SyndicationItem>();

            var products = _productService.SearchProducts(
                storeId: _storeContext.CurrentStore.Id,
                orderBy: ProductSortingEnum.CreatedOn,
                pageSize: _catalogSettings.RecentlyAddedProductsNumber);
            foreach (var product in products)
            {
                string productUrl = Url.RouteUrl("Product", new { SeName = product.GetSeName() }, "http");

                var item = new SyndicationItem(product.GetLocalized(x => x.Name), product.GetLocalized(x => x.ShortDescription), new Uri(productUrl), String.Format("RecentlyAddedProduct:{0}", product.Id), product.CreatedOnUtc);

                var pictures = _pictureService.GetPicturesByProductId(product.Id);
                if (pictures.Count > 0)
                {
                    var imageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault(), _mediaSettings.ProductDetailsPictureSize);
                    item.ElementExtensions.Add(
                        new XElement("enclosure", new XAttribute("type", "image/jpeg"), new XAttribute("url", imageUrl)).CreateReader()
                    );
                }

                items.Add(item);
            }
            feed.Items = items;
            return new RssActionResult() { Feed = feed };
        }



Is there a way for it to not show up as a link but the picture itself?
6 anni tempo fa
algorithmer wrote:
In CatalogController use this code (v3.00):


       public ActionResult RecentlyAddedProductsRss()
        {
            var feed = new SyndicationFeed(
                                    string.Format("{0}: Recently added products", _storeContext.CurrentStore.Name),
                                    "Information about products",
                                    new Uri(_webHelper.GetStoreLocation(false)),
                                    "RecentlyAddedProductsRSS",
                                    DateTime.UtcNow);

            if (!_catalogSettings.RecentlyAddedProductsEnabled)
                return new RssActionResult() { Feed = feed };

            var items = new List<SyndicationItem>();

            var products = _productService.SearchProducts(
                storeId: _storeContext.CurrentStore.Id,
                orderBy: ProductSortingEnum.CreatedOn,
                pageSize: _catalogSettings.RecentlyAddedProductsNumber);
            foreach (var product in products)
            {
                string productUrl = Url.RouteUrl("Product", new { SeName = product.GetSeName() }, "http");

                var item = new SyndicationItem(product.GetLocalized(x => x.Name), product.GetLocalized(x => x.ShortDescription), new Uri(productUrl), String.Format("RecentlyAddedProduct:{0}", product.Id), product.CreatedOnUtc);

                var pictures = _pictureService.GetPicturesByProductId(product.Id);
                if (pictures.Count > 0)
                {
                    var imageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault(), _mediaSettings.ProductDetailsPictureSize);
                    item.ElementExtensions.Add(
                        new XElement("enclosure", new XAttribute("type", "image/jpeg"), new XAttribute("url", imageUrl)).CreateReader()
                    );
                }

                items.Add(item);
            }
            feed.Items = items;
            return new RssActionResult() { Feed = feed };
        }


I feel so silly for asking this question as I am new to nopcommerce. However, where do I find CatalogController?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.