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.
Il y a 12 ans
Images are in the Blog's RSS.   They are not in the New Products RSS.
(Which RSS are you concerned with?)
Il y a 12 ans
I am concerned about New Products RSS.
Il y a 12 ans
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),
                };
Il y a 12 ans
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..
Il y a 12 ans
CatalogController also contains
        public ActionResult RecentlyAddedProductsRss()

You would need to figure out how to modify  RecentlyAddedProductsRss(), to use above  ImageUrl = _pictureService.GetPictureUrl(...
Il y a 12 ans
I am not able to figure out how to pull image, it would be great if you could help me on this..
Il y a 11 ans
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 };
        }
Il y a 11 ans
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?
Il y a 6 ans
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.