GoogleBot Picking up incorrect currency

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 года назад
Hi,

I recently upgraded to NOP 4.4 from 4.1 and all the products the Google search results are now showing in the currency where the Google Bot is located. After some investigation, it looks like Nop is automatically changing the currency depending on the location of the person browsing the site.

Can anybody help me with this?

Please note we sell only digital downloads and as far as I am aware you cannot use the Google Merchant Center to advertise, but it would be good to see the products again as they have all mostly been removed by Google.

https://clickalgo.com
2 года назад
Make this an issue over on Github :)

https://github.com/nopSolutions/nopCommerce/issues

And is this related? https://www.nopcommerce.com/en/boards/topic/50594/google-merchant-centre-caching-wrong-currency
2 года назад
Thanks again, us,

I will investigate further and if I cannot find a 3rd party plugin that is doing this then I will post a bug report, but it seems no one else has raised this issue yet.
2 года назад
THE FIX
I managed to correct the issue by adding some additional settings in the CommonModelFactory.cs robot file generator.

"/changecurrency/*",
"/changecurrency/",

When I ran the Structured data testing tool it was still scraping other currencies, but mostly SEK, I unpublished the SEK currency and all products now show the correct currency on Google search, the problem was either the default /Changecurrency setting in the robots file was not working and needed the /changecurrency/* as this is now used to block /changecurrency/7 or an issue with the Swedish currency.

I hope the information above helps in the future.
2 года назад
UPDATE

Looks like the above did not work, the Markup tool has reverted to euros now, if I unpublish the EUR currency it goes back to GBP, something in the website is setting the currency based on the GoogleBot location, I have asked my customers and they say it defaults as GBP.

Any ideas anyone, does Nop change the currency based on IP?
2 года назад
I unpublished all currencies apart from GBP and now when I ask Google to scrape the site it returns the correct currency and price, if anyone can help me with this issue, I would be eternally grateful.

The site does use a 3rd party theme and I have contacted the company in the event that they have some logic in their code that sets the currency based on geolocation.
2 года назад
I encountered this when checking "Automatically detect language" in yoursite.com/Admin/Setting/GeneralCommon

Most GoogleBots are supposed to originate from the USA, but since all crawlers get referenced to the built-in SearchEngine customer account (Id = 2) it was picking up cached/saved languages and currencies from the previous crawler, and my site was getting indexed in all sorts of random languages and currencies.

So I overrode WorkingLanguage and WorkingCurrency in Nop.Web.Framework/WebWorkContext.cs to bypass detection/saving anything to genericattributes, and just returning my store's default language/currency as soon as possible for all search engines:


       public override Language WorkingLanguage
        {
            get
            {
                var allStoreLanguages = _languageService.GetAllLanguages(storeId: _storeContext.CurrentStore.Id);

                //override to force english for search engines
                if (CurrentCustomer.IsSearchEngineAccount())                
                    _cachedLanguage = allStoreLanguages.FirstOrDefault(language => language.Id == _storeContext.CurrentStore.DefaultLanguageId);

                
                //whether there is a cached value
                if (_cachedLanguage != null)                
                    return _cachedLanguage;



       public override Currency WorkingCurrency
        {
            get
            {
                //whether there is a cached value
                if (_cachedCurrency != null)
                    return _cachedCurrency;

                //return primary store currency when we're in admin area/mode
                //override to force USD for search engines
                if (IsAdmin || CurrentCustomer.IsSearchEngineAccount())

                {
                    var primaryStoreCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);
                    if (primaryStoreCurrency != null)
                    {
                        _cachedCurrency = primaryStoreCurrency;
                        return primaryStoreCurrency;
                    }
                }
2 года назад
SOLUTION ABOVE WORKS

Thank you very much, when I now run the Google Structured Markup Tool it comes back with the correct primary store currency, I just need to wait for Google to re-index all the products and show them again, currently, they have all been removed at a financial cost.

As I am using NOP 4.4, I updated the code slightly:


if (IsAdmin || customer.IsSearchEngineAccount())
{
    var primaryStoreCurrency = await _currencyService.GetCurrencyByIdAsync(_currencySettings.PrimaryStoreCurrencyId);
    if (primaryStoreCurrency != null)
    {
        _cachedCurrency = primaryStoreCurrency;
        return primaryStoreCurrency;
    }
}
return _cachedCurrency;
2 года назад
phayes wrote:
As I am using NOP 4.4, I updated the code slightly:


right, sorry, I'm still on 4.2ish

if you sign up for/have access to google's search console you can request a re-index by pointing it to yourwebsite.com/sitemap.xml (assuming you have it enabled), which should run within a few days:
https://developers.google.com/search/docs/advanced/crawling/ask-google-to-recrawl  

(I had to disable products from the XML settings because I have 100k+ products and google didn't get a response quickly enough, but it should find everything from the categories)
2 года назад
nice one, thanks for helping me.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.