{"id":1261,"date":"2013-03-05T08:58:50","date_gmt":"2013-03-05T08:58:50","guid":{"rendered":"http:\/\/www.bennewitz.com\/devel\/?p=1261"},"modified":"2014-02-04T15:54:29","modified_gmt":"2014-02-04T15:54:29","slug":"magento-shopper-theme-and-vto","status":"publish","type":"post","link":"https:\/\/www.bennewitz.com\/devel\/magento-shopper-theme-and-vto\/","title":{"rendered":"Magento, Shopper theme and VTO"},"content":{"rendered":"<p>Last week I have updated bennewitz.com and I was able to fix a long time bug of Magento. \u00a0The problem appears when I change the language from German to English. The names of the categories are different &#8211; that&#8217;s why I receive an 404 error. There was no translation of the category name, based by the category ID.<\/p>\n<p>This is a very nasty error.<\/p>\n<p>Looking into the code I found that I had removed the &#8220;?___from_store=xx&#8221;output in past for better SEO:\u00a0Inside of \/app\/design\/frontend\/base\/default\/template\/page\/switch\/languages.phtml &#8220;getCurrentUrl()&#8221; was set to &#8220;getCurrentUrl(false)&#8221;.<\/p>\n<p>This was a bad idea because this avoids the translation of the category name. However setting this back to default the language switcher doesn&#8217;t work as expected. Even the category name is translated the store code is still missed.<\/p>\n<p>In result I had to look some deeper inside the php&#8230; for Magento 1.7.0.2 I have found this fix:<\/p>\n<p>\/app\/code\/core\/Mage\/Core\/Model\/Url\/Rewrite.php<\/p>\n<p>Starting from line 251 I have replaced the default assignment to $targetUrl<\/p>\n<p>Mage::app()-&gt;getCookie()-&gt;set(Mage_Core_Model_Store::COOKIE_NAME, $currentStore-&gt;getCode(), true);<\/p>\n<pre><code>\/\/ endur 02-03-2013 fix for missed store code\r\n\/\/ $targetUrl = $request-&gt;getBaseUrl(). '\/' . $this-&gt;getRequestPath();\r\n\r\nif (Mage::getStoreConfig('web\/url\/use_store') &amp;&amp; $storeCode\r\n    = Mage::app()-&gt;getStore()&gt;getCode()) { \r\n    $targetUrl = $request-&gt;getBaseUrl(). '\/'\r\n     . $storeCode . '\/' .$this-&gt;getRequestPath();\r\n    } else {\r\n      $targetUrl = $request-&gt;getBaseUrl(). '\/' . $this-&gt;getRequestPath();\r\n    }\r\n\r\n\/\/ endur 02-03-2013 end\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>to get the store code added. It seem&#8217;s a bug of Magento 1.7.0.2.<br \/>\nOf course I havn&#8217;t change the core file itself, I have changed a copy instead:<\/p>\n<p>\/app\/code\/local\/Mage\/Core\/Model\/Url\/Rewrite.php<\/p>\n<p>&#8230;and the language switcher is working well from now \ud83d\ude09<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week I have updated bennewitz.com and I was able to fix a long time bug of Magento. \u00a0The problem appears when I change the [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-1261","post","type-post","status-publish","format-standard","hentry","category-virtual-mirror-and-magento"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.bennewitz.com\/devel\/wp-json\/wp\/v2\/posts\/1261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bennewitz.com\/devel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bennewitz.com\/devel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bennewitz.com\/devel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bennewitz.com\/devel\/wp-json\/wp\/v2\/comments?post=1261"}],"version-history":[{"count":0,"href":"https:\/\/www.bennewitz.com\/devel\/wp-json\/wp\/v2\/posts\/1261\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bennewitz.com\/devel\/wp-json\/wp\/v2\/media?parent=1261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bennewitz.com\/devel\/wp-json\/wp\/v2\/categories?post=1261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bennewitz.com\/devel\/wp-json\/wp\/v2\/tags?post=1261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}