Newbie Magento developer here, but I'll try to keep it structured.
Site architecture:
- Magento 1.8
- Multi-store (1 store for 1 language)
- Lightly modded by last developer (I think most if not all the core files are in a pristine, untouched condition).
- DressCode Magento Template
- Store code in URL -> true
- SEO friendly URL -> true
Problem:
When under a single product view (ie. store.com/en/shoes/guess-green-shoes.html) the store switcher in the header does not generate the correct URL. IE. if I clicked on the german switch, then the address is "store.com/de/shoes/guess-grone-schuhe.html", but it should rather be "store.com/de/schuhe/guess-grone-schuhe.html".
implicitly this means that the category slug is not getting translated and I don't know how I should act. Any advice from the more experienced players?
What I have tried:
Checked URL rewrite management, where the situation is as follows
Request path Target path
correct_de_link X
correct_en_link X
correct_it_link X
correct_xx_link means that the link is fine, with the category and product name translated. Thus I think this is correct.
I also figured that I'd change the core classes Mage_Core_Controller_Request_Http->setPathInfo(); or Mage_Core_Model_Store->getCurrentUrl(); But I think this is needless and would only mask the probem.
What I will do if I don't get an answer:
I will parse the category string with the php explode() function and then translate it between stores by name and store id. Then I will manually add it to the store switcher.
Hei guys
So I dug deeper into the problem and found out it was caused by the _rewriteDb function in the class Mage_Core_Model_Url_Rewrite_Request.
Namely the __from_store get variable was "en", "lv".. for different stores and the Magento core tried to use this variable to access the stores array, but instead it needed the store id that is connected to the store code. So I added a line ( between " - REWRITE HACK" ) to remedy the issue and everything is working as expected now.