Wednesday, 18 September 2013

Remove Switch StoreView URL in Magento

Remove Switch StoreView URL  in Magento

www,mydomain.com/sp/?___from_store=default
or
www,mydomain.com/fr/?___from_store=sp

How to Avoid this   /fr/?___from_store=sp from url


Step ( i ):-

     System->Configuration->Web->Url Options. and Add Store Code to Urls change 'Yes'.



Step (ii) :-

If you look into /app/code/core/Mage/Core/Model/Store.php you see following function:

public function getCurrentUrl($fromStore true)

So without changing any core code grab /app/design/frontend/base/default/template/page/switch/languages.phtml

 Change the line

<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>

to
<option value="<?php echo $_lang->getCurrentUrl(false) ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>

and put the changed file into the corresponding path of your theme folder.
And now you have clean URLs. 

No comments:

Post a Comment