Magento, Shopper theme and VTO

Last week I have updated bennewitz.com and I was able to fix a long time bug of Magento.  The problem appears when I change the language from German to English. The names of the categories are different – that’s why I receive an 404 error. There was no translation of the category name, based by the category ID.

This is a very nasty error.

Looking into the code I found that I had removed the “?___from_store=xx”output in past for better SEO: Inside of /app/design/frontend/base/default/template/page/switch/languages.phtml “getCurrentUrl()” was set to “getCurrentUrl(false)”.

This was a bad idea because this avoids the translation of the category name. However setting this back to default the language switcher doesn’t work as expected. Even the category name is translated the store code is still missed.

In result I had to look some deeper inside the php… for Magento 1.7.0.2 I have found this fix:

/app/code/core/Mage/Core/Model/Url/Rewrite.php

Starting from line 251 I have replaced the default assignment to $targetUrl

Mage::app()->getCookie()->set(Mage_Core_Model_Store::COOKIE_NAME, $currentStore->getCode(), true);

// endur 02-03-2013 fix for missed store code
// $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath();

if (Mage::getStoreConfig('web/url/use_store') && $storeCode
    = Mage::app()->getStore()>getCode()) { 
    $targetUrl = $request->getBaseUrl(). '/'
     . $storeCode . '/' .$this->getRequestPath();
    } else {
      $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath();
    }

// endur 02-03-2013 end

 

to get the store code added. It seem’s a bug of Magento 1.7.0.2.
Of course I havn’t change the core file itself, I have changed a copy instead:

/app/code/local/Mage/Core/Model/Url/Rewrite.php

…and the language switcher is working well from now ;-)

 

2 Comments

  1. Thanks for the info, but it doesnt work for me…

    I have magento 1.7.0.2, i make the changes in Rewrite.php, i clean the cache but the web stills shows “?___from_store=” when i change the language, and if i change getCurrentUrl()” to “getCurrentUrl(false) i get a 404 error.

    What im doing wrong? Can you help me please?

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>