Magento Forum

   
Custom product url + store code in url gives 404 page not found when switching to other storeview (storecode gone). 
 
Echron
Jr. Member
 
Avatar
Total Posts:  2
Joined:  2010-11-03
Belgium
 

When i’m on a product page and i switch to an other storeview/language i get an 404 because there is no storecode in the url:

Original product page:
http://shop.curasano.com/cur_nl/masker-voor-hals-en-gelaat.html

The url to switch to the english storeview (in the storeswitch):

http://shop.curasano.com/cur_en/masker-voor-hals-en-gelaat.html?___store=cur_en&___from_store=cur_nl

When i click on “english” i get following url: (404 Not Found). You can see there is no language code in this url.

http://shop.curasano.com/mask-for-face-neck.html

But when i look at the storeswitch i see that magento knows on witch product i am:

<select onchange="[removed].href=this.value" title="Your Language" id="select-language">
  <
option value="http://shop.curasano.de/cur_de/mask-for-face-neck.html?SID=e8geskl93fvjht1borqddltd81&amp;___from_store=cur_en">Deutsch</option>
  <
option selected="selected" value="http://shop.curasano.com/cur_en/mask-for-face-neck.html?___from_store=cur_en">English</option>
  <
option value="http://shop.curasano.com/cur_fr/mask-for-face-neck.html?___from_store=cur_en">Français</option>
  <
option value="http://shop.curasano.com/cur_nl/mask-for-face-neck.html?___from_store=cur_en">Nederlands</option>
        </
select>

 
Magento Community Magento Community
Magento Community
Magento Community
 
karoliskr
Jr. Member
 
Total Posts:  1
Joined:  2011-06-12
 

I have exactly the same problem with categories. Magento loses store code…

 
Magento Community Magento Community
Magento Community
Magento Community
 
rj8webdesign
Jr. Member
 
Total Posts:  2
Joined:  2011-05-22
 

Solution (for me):

Modify this file: /app/code/core/Mage/Core/Model/Url/Rewrite.php around line 252, comment line:

// $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath();

and substitute with this code:

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

Source: http://samuiweb.net/magento-store-code-url-bug/
Just posting it here for google and in case the source goes 404.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cossy
Jr. Member
 
Total Posts:  1
Joined:  2011-03-31
 

This fix works also perffectly in the Community edition 1.7.0.2

Had the same problem, but works great now.

Thanks smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top