Google Froogle Feed bug report for multiple stores

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 9 ans
Hi,
I have found a bug if multiple stores are used.
The Froogle generates for each store a file. The input to the file is the store in GenerateFeed(...store)..
However, for the category the next function is called. This function has caching on the current store context. This makes that a wrong category is given back.

Call in GenerateFeed:

//product type [product_type] - Your category of the item
                        var defaultProductCategory = _categoryService.GetProductCategoriesByProductId(product.Id).FirstOrDefault();
                        if (defaultProductCategory != null)
                        {
                            var category = defaultProductCategory.Category.GetFormattedBreadCrumb(_categoryService, separator: ">");
                            if (!String.IsNullOrEmpty((category)))
                            {
                                writer.WriteStartElement("g", "product_type", googleBaseNamespace);
                                writer.WriteCData(category);
                                writer.WriteFullEndElement(); // g:product_type
                            }
                        }


Function call of
GetProductCategoriesByProductId

/// <summary>
        /// Gets a product category mapping collection
        /// </summary>
        /// <param name="productId"> Product identifier</param>
        /// <param name="showHidden"> A value indicating whether to show hidden records</param>
        /// <returns> Product category mapping collection</returns>
        public virtual IList<ProductCategory> GetProductCategoriesByProductId(int productId, bool showHidden = false)
        {
            if (productId == 0)
                return new List<ProductCategory>();

            string key = string.Format(PRODUCTCATEGORIES_ALLBYPRODUCTID_KEY, showHidden, productId, _workContext.CurrentCustomer.Id, _storeContext.CurrentStore.Id);
            return _cacheManager.Get(key, () =>
            {

correct implementation should cache for storeid and check limitations per store as well.
Il y a 9 ans
Hi J.,

Thanks a lot for reporting. You're absolutely right. I've just created a work item
Il y a 9 ans
Fixed. Please see changeset a8f1b2ce3595
Il y a 9 ans
Temporarily fix --> does not take acl authorization into account.

Also does throw errors at Google if Category.Visible = false or category.published=false. No product_type will be given in such cases.

==> Would be nice to integrate Include and GoogleCondition from GoogleShoppingAdvanced so that refurbished products can be shown. And also that not all products need to be included. I have also some fixed on that.


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Nop.Core.Caching;
using Nop.Core.Data;
using Nop.Core.Domain.Catalog;
using Nop.Core.Domain.Stores;
using Nop.Plugin.Feed.GoogleShoppingAdvanced.Domain;
using Nop.Services.Security;
using Nop.Services.Stores;

namespace Nop.Plugin.Feed.GoogleShoppingAdvanced.Services
{
    public partial class GoogleAdvancedCategoryService : IGoogleAdvancedCategoryService
    {
        #region Constants

        private const string PRODUCTCATEGORIES_ALLBYSTOREID_PRODUCTID_KEY = "Nop.productcategory.allbystore_productid-{0}-{1}";

        #endregion

        #region Fields
        
        private readonly ICacheManager _cacheManager;
        private readonly IRepository<Category> _categoryRepository;
        private readonly IRepository<ProductCategory> _productCategoryRepository;                
        private readonly IRepository<StoreMapping> _storeMappingRepository;

        //not used yet (_storeContext in them)
        //private readonly IStoreMappingService _storeMappingService;                
        //private readonly IAclService _aclService;
        
        #endregion

        #region Ctor

       /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="cacheManager">Cache manager</param>
        /// <param name="categoryRepository">Category repository</param>
        /// <param name="productCategoryRepository">ProductCategory repository</param>
        public GoogleAdvancedCategoryService(
            ICacheManager cacheManager,
            IRepository<Category> categoryRepository,
            IRepository<ProductCategory> productCategoryRepository,        
            IRepository<StoreMapping> storeMappingRepository
            )
        {        
            this._cacheManager = cacheManager;
            this._categoryRepository = categoryRepository;
            this._productCategoryRepository = productCategoryRepository;
            this._storeMappingRepository = storeMappingRepository;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Gets a product category mapping collection
        /// </summary>
        /// <param name="productId"> Product identifier</param>
        /// <param name="showHidden"> A value indicating whether to show hidden records</param>
        /// <returns> Product category mapping collection</returns>
        public virtual IList<ProductCategory> GetProductCategoriesByProductId(int storeId, int productId)
        {
            if (productId == 0)
                return new List<ProductCategory>();

            string key = string.Format(PRODUCTCATEGORIES_ALLBYSTOREID_PRODUCTID_KEY, storeId, productId);
            return _cacheManager.Get(key, () =>
            {
                var query = from pc in _productCategoryRepository.Table
                            join c in _categoryRepository.Table on pc.CategoryId equals c.Id
                            join sm in _storeMappingRepository.Table
                            on new { c1 = c.Id, c2 = "Category" } equals new { c1 = sm.EntityId, c2 = sm.EntityName } into c_sm
                            from sm in c_sm.DefaultIfEmpty()
                            where (!c.LimitedToStores || storeId == sm.StoreId)
                                &&
                                (pc.ProductId == productId && !c.Deleted && c.Published)
                            orderby pc.DisplayOrder
                            select pc;

                var result = query.ToList();

                return result;
            });
        }
        #endregion
    }
}
Il y a 9 ans
a.m. wrote:
Fixed. Please see changeset a8f1b2ce3595


I have found a bug with this in version 3.40 that maybe was fixed in 3.50??

I have 2 stores configured in my site. The feed I generate for store1 has all necessary product attributes to satisfy google merchant center, but the feed for store2 is missing the 'product_type' attribute.

Line 1 Missing recommended attribute- product type. While items missing recommended attributes will process successfully, we recommend including relevant attributes if they are available


examples:
store1- http://www.myfootshop.com/content/files/exportimport/1-froogle_2275741629.xml
store2- http://www.naturalfootcareproducts.com/content/files/exportimport/2-froogle_2275741629.xml

Was this also fixed in 3.50?

Thanks,
Steve
Il y a 9 ans
Hi,
Take notice that I have a different version that the NOP default plugin! I guess you run into the issue with storeId.
J.


//product type [product_type] - Your category of the item
                            var defaultProductCategory = _categoryService.GetProductCategoriesByProductId(product.Id, store.Id).FirstOrDefault();                            
                            if (defaultProductCategory != null)
                            {
                                var category = defaultProductCategory.Category.GetFormattedBreadCrumb(_categoryService, separator: ">");
                                if (!String.IsNullOrEmpty((category)))
                                {
                                    if (category.Length > 750)
                                        category = category.Substring(0, 750);

                                    writer.WriteElementString("g", "product_type", googleBaseNamespace, category);

                                }
                            }
Il y a 9 ans
OK...this problem is very strange.
Today, on a whim, I generated the store2 feed again, and this time all product_type attributes were included in the feed!

However... none of my product weights are included in the feed, so they are being completely rejected by google...

I tried generating the feed again today after editing each of the products to have a different weight, and still no product weights are included in the google feed for store2.

Has anyone got any ideas about getting around this problem (other than to manually add the weight attribute/values to each item in my feed)?

Also...will this be fixed in or before next release?

Thanks,
Steve
Il y a 9 ans
***HELP***
This problem is much worse than I thought!
We really depend on the traffic we get from the Google Shopping program, and now we aren't getting any at all.

Evidently, when I first generated the feed for store2, which for some reason has no shipping_weights included, it made it so that my store1 feed also has no shipping_weights included, so all of our products have been disapproved from Google Shopping!

Actually, I've looked back at old copies of my feed and the <g: shipping_weight> attribute has never been included, so I do not understand why now this is a problem for Google...and not last January, when we first switched to nopcommerce. Whatever the case, it's a problem now for sure!

Are you aware that the feed specifications require shipping weights if you specify either 'rate table' or 'carrier-based' rates in google merchant center shipping settings? Shouldn't this attribute already be included in the feed?
Missing 'shipping weight' attribute.157 errors.
Shipping weight must be specified in 'shipping weight' attribute if a weight-based rule is defined in Google Merchant Center.
Learn more

My only option is to manually add the attribute to each of my products in the XML, but because we frequently update our products information, it will be necessary to do so each time...that's going to be a crazy amount of work to paste in this tag and edit it to have correct weights for 150 different products, every time I generate a new feed, which is at least once per month, and sometimes many more.

<g:shipping_weight>
<![CDATA[ 4 oz ]]>
</g:shipping_weight>


PLEASE PLEASE PLEASE update this plugin by adding this attribute, and make it available for download ASAP!

And for some reason, on the feed for store2, the few products that do include the product_type attribute, the values are populated with categories that are limited to store1! Seems very buggy...

Steve
Il y a 9 ans
embryo wrote:
'shipping weight' attribute
...
PLEASE PLEASE PLEASE update this plugin by adding this attribute, and make it available for download ASAP!

Hi Steve,

It's already supported. Just ensure that "frooglesettings.passshippinginfo" setting is set to "true" (also available on the plugin  configuration page since version 3.50 - demo here)
Il y a 9 ans
a.m. wrote:
'shipping weight' attribute
...
PLEASE PLEASE PLEASE update this plugin by adding this attribute, and make it available for download ASAP!
Hi Steve,

It's already supported. Just ensure that "frooglesettings.passshippinginfo" setting is set to "true" (also available on the plugin  configuration page since version 3.50 - demo here)


Wow! I feel so stupid for not looking through the advanced settings!
Re-generating my feed now-

Thanks,
Steve
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.