Google Shopping Plugin - Secure URL

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
I recently encountered a problem with Bing Ads because the product URL is being redirected to the HTTPS version, since my site is fully SSL encrypted.

I suggest the following change on the Google Shopping plug in in the Plugins/Nop.Plugin.Feed.GoogleShopping/GoogleShoppingService.cs file:

From:

//link [link] - URL directly linking to your item's page on your website
var productUrl = $"{store.Url}{product.GetSeName(languageId)}";
writer.WriteElementString("link", productUrl);



TO:

//link [link] - URL directly linking to your item's page on your website
//If SSL enabled use secureURL
if (store.SslEnabled)
{
var productUrl = string.Format("{0}{1}", store.SecureUrl, product.GetSeName(languageId));
writer.WriteElementString("link", productUrl);
}
else
{
var productUrl = string.Format("{0}{1}", store.Url, product.GetSeName(languageId));
writer.WriteElementString("link", productUrl);
}
6 years ago
Accordingly the Image URL section also needs to be updated:


//image link [image_link] - URL of an image of the item
                            //additional images [additional_image_link]
                            //up to 10 pictures
                            const int maximumPictures = 10;
                            var pictures = _pictureService.GetPicturesByProductId(product.Id, maximumPictures);
                            for (int i = 0; i < pictures.Count; i++)
                            {
                                var picture = pictures[i];
                                string imageUrl;
                                if (store.SslEnabled)
                                {
                                    imageUrl = _pictureService.GetPictureUrl(picture,
                                    _froogleSettings.ProductPictureSize,
                                    storeLocation: store.SecureUrl);
                                }
                                else
                                {
                                    imageUrl = _pictureService.GetPictureUrl(picture,
                                    _froogleSettings.ProductPictureSize,
                                    storeLocation: store.Url);
                                }

                                if (i == 0)
                                {
                                    //default image
                                    writer.WriteElementString("g", "image_link", googleBaseNamespace, imageUrl);
                                }
                                else
                                {
                                    //additional image
                                    writer.WriteElementString("g", "additional_image_link", googleBaseNamespace, imageUrl);
                                }
                            }
                            if (pictures.Count == 0)
                            {
                                //no picture? submit a default one
                                string imageUrl;
                                if (store.SslEnabled)
                                {
                                    imageUrl = _pictureService.GetDefaultPictureUrl(_froogleSettings.ProductPictureSize, storeLocation: store.SecureUrl);
                                    writer.WriteElementString("g", "image_link", googleBaseNamespace, imageUrl);
                                }
                                else
                                {
                                    imageUrl = _pictureService.GetDefaultPictureUrl(_froogleSettings.ProductPictureSize, storeLocation: store.Url);
                                    writer.WriteElementString("g", "image_link", googleBaseNamespace, imageUrl);
                                }
                            }
6 years ago
Hi Chris,

Thanks a lot for suggestion. Here is a work item
6 years ago
And done (with a litle bit less source code duplication). Thanks again
6 years ago
Excellent!

Though minuscule, it's nice to give something back!

Yeah, your version is much simpler!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.