# Google feed wrong language

**URL:** <https://forum.litium.com/t/google-feed-wrong-language/545>\
**Category:** Questions\
**Tags:** litium-5\
**Created:** [February 1, 2019, 1:04pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545 "2019-02-01T13:04:42Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![dannyboy](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/dannyboy/32/55_2.png) [@dannyboy](https://forum.litium.com/u/dannyboy)\
**Post date:** [February 1, 2019, 1:04pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/1 "2019-02-01T13:04:42Z")

</div>

Hey!

We got the same code running on 3 machines, 2 local and on production server. When we view the google shopping feed on the swedish site all the names, descriptions etc of the products are in swedish except of some “ProductCategory” fields which are shown in other languages.  
On our local machines all the data is in swedish but in production the “ProductCategory” fields are in english and after we reindexed the site ProductCategory is in german.  
Feels like there is some bug in the base factory when it gets the culture of that property?

We have overriden the factory and it looks like this:

```
    public override PriceAgentItemResult Create(PriceAgentItemArgs priceAgentItemArgs)
    {
        var website = _moduleCms.WebSites.GetWebSite(priceAgentItemArgs.WebSiteSystemId);
        var defaultWebsite = _moduleCms.WebSites.DefaultWebSite;
        var result = base.Create(priceAgentItemArgs);
        
        result.ProductCategory = result.ProductCategory?.Replace("-", " > "); // Replace separator for categories
        
        .....
        
    }

```

We dont do anything with the category except replace the dashes. This has worked perfectly before and I’m suspecting it might be a bug in a recent Litium release.

Litium version: 5.6.6-PATCH-1811231133

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 1, 2019, 1:53pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/2 "2019-02-01T13:53:33Z")

</div>

The Google Shopping Feed is using the property `priceAgentItemResult.Properties["GoogleProductCategory"]` for the category information and not the `result.ProductCategory`.

To be able to help out more we need to know how the setup of websites including domain name structure (not needed to have the real domain name but the some example how your sites are configured).

---

<div class="post-metadata">

**Author:** ![dannyboy](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/dannyboy/32/55_2.png) [@dannyboy](https://forum.litium.com/u/dannyboy)\
**Post date:** [February 1, 2019, 2:00pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/3 "2019-02-01T14:00:35Z")

</div>

We use both the “GoogleProductCategory” and the priceAgentItemResult.ProductCategory in our feed as shown below:

new XElement(ns + “google\_product\_category”,  
GoogleShoppingHelper.SafeGetPropertyValue(priceAgentItemResult,  
GoogleShoppingConstants.GoogleCategory)),  
new XElement(ns + “product\_type”, priceAgentItemResult.ProductCategory),

Result (on the swedish feed):  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/de14b5a12a46aca5944727b65436451ffee8a9f1.png)

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 1, 2019, 2:10pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/4 "2019-02-01T14:10:28Z")

</div>

To be able to help out more we need to know how the setup of websites including domain name structure (not needed to have the real domain name but the some example how your sites are configured).

---

<div class="post-metadata">

**Author:** ![dannyboy](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/dannyboy/32/55_2.png) [@dannyboy](https://forum.litium.com/u/dannyboy)\
**Post date:** [February 1, 2019, 2:22pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/5 "2019-02-01T14:22:34Z")

</div>

Hello Patric, i sent you some info on slack so you have a better view of our project

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 1, 2019, 5:48pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/6 "2019-02-01T17:48:53Z")

</div>

The default `Litium.Web.Products.PriceAgents.IPriceAgentItemFactory` is registered as `Transient` in DI engine and in your implementation you are changing this to `Singelton` because your attribute is not having any lifetime assigned.

![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/cd0c26cbbdbdf7136dd090ccb4e44e8fd912fb28.png)

You should be able to remove then `[Service]`-attribute and the DI engine should find your implementation anyway because it inherit the interface `IPriceAgentItemFactory` that is automatic registered.

In the default `PriceAgentItemFactory` it exists an cache for the category names and now the cache will be shared between all the different websites.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 4, 2019, 4:18pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/7 "2019-02-04T16:18:05Z")

</div>

@dannyboy Did you get it to work?

---

<div class="post-metadata">

**Author:** ![dannyboy](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/dannyboy/32/55_2.png) [@dannyboy](https://forum.litium.com/u/dannyboy)\
**Post date:** [February 5, 2019, 1:54pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/8 "2019-02-05T13:54:55Z")

</div>

Edited this comment because the problem didn’t get solved as I thought.

---

<div class="post-metadata">

**Author:** ![stefan.gross](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@stefan.gross](https://forum.litium.com/u/stefan.gross)\
**Post date:** [February 6, 2019, 8:43am UTC](https://forum.litium.com/t/google-feed-wrong-language/545/9 "2019-02-06T08:43:27Z")

</div>

@patric.forsgard it seems like the problem has returned. We’ve drawn the conclusion when the PriceAgentItemResult.StockStatusDescription is “out of stock” the category name changes language.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 6, 2019, 10:03am UTC](https://forum.litium.com/t/google-feed-wrong-language/545/10 "2019-02-06T10:03:38Z")

</div>

Will it be the same if you replace the code you have for the `IStockStatusMessageService` implementation in accelerator into the following?

```auto
using Litium.Products.StockStatusCalculator;
using Litium.Studio.Extenssions;

namespace Litium.Accelerator.Services
{
    internal class StockStatusMessageServiceImpl : IStockStatusMessageService
    {
        public StockStatusCalculatorResult Populate(StockStatusCalculatorArgs calculatorArgs, StockStatusCalculatorItemArgs calculatorItemArgs, StockStatusCalculatorResult result)
        {
            result.Description = ((calculatorItemArgs.Quantity == 0
                ? result.InStockQuantity > 0
                : result.InStockQuantity >= calculatorItemArgs.Quantity) ? "PriceAgentInStockWithoutQuantity" : "PriceAgentOutOfStockWithoutQuantity")
                .AsWebSiteString(webSiteId: calculatorArgs.WebSiteSystemId);
            return result;
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![stefan.gross](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@stefan.gross](https://forum.litium.com/u/stefan.gross)\
**Post date:** [February 6, 2019, 12:25pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/11 "2019-02-06T12:25:42Z")

</div>

Its not the out of stock message that is incorrect. Its the product categories that gets translated. But that seem to happen when the products are indeed out of stock. I tried with your code, but that didnt change anything.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 6, 2019, 2:51pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/12 "2019-02-06T14:51:14Z")

</div>

Something in the code is changing the culture on the current thread, this is making the categories to return the name in wrong translation. Where the code that is changing the culture on the thread during the execution is hard to tell.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 6, 2019, 3:16pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/13 "2019-02-06T15:16:50Z")

</div>

I think you need to debug your code to see what is happening. What I can see when I check on the assemblies is that you have a lot of own modifications that you need to fix.

Example is this static variable that will hold a static `IPriceAgentItemFactory` between all the request independent of the entered website that will cause the cache that I talk about earlier to be shared between all requests.  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/8ec3e50c9fac7e2a24f553d3c00237a16a2282f5.png)

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [February 6, 2019, 3:53pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/14 "2019-02-06T15:53:52Z")

</div>

Static objects should be avoided as recommendation from most developers.

> <https://stackoverflow.com/questions/7026507/why-are-static-variables-considered-evil>

---

<div class="post-metadata">

**Author:** ![stefan.gross](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@stefan.gross](https://forum.litium.com/u/stefan.gross)\
**Post date:** [February 12, 2019, 11:19am UTC](https://forum.litium.com/t/google-feed-wrong-language/545/15 "2019-02-12T11:19:35Z")

</div>

I re-factored everything so no static objects are being used. That was a misstake in the first place. However the problem remains.  
new XElement(ns + “availability”, priceAgentItemResult.StockStatusDescription) when this results in “out of stock”  
new XElement(ns + “product\_type”, priceAgentItemResult.ProductCategory)\<-- product category end up being in a language not for the current website.

---

<div class="post-metadata">

**Author:** ![stefan.gross](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@stefan.gross](https://forum.litium.com/u/stefan.gross)\
**Post date:** [February 12, 2019, 12:38pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/16 "2019-02-12T12:38:04Z")

</div>

So i finally found the problem and it had nothing to do with what we discussed before. It was actually creating priceAgentItemResults without making sure the product was published for the current site priceAgentItemResults.Add(\_priceAgentItemFactory.Create(new PriceAgentItemArgs(baseProduct, variant, websiteId)));  
When running this code on an unpublished product for the current site, it seems that the url gets taken from a random other site that has the product published.

@patric.forsgard i let you decide if this should be considered a bug or not.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 12, 2019, 12:44pm UTC](https://forum.litium.com/t/google-feed-wrong-language/545/17 "2019-02-12T12:44:29Z")

</div>

The code that is fetching the variants is in the project file `GoogleShoppingHelper` so I consider that to be a project instead of a product bug.
