Force Removal of Store Code (?___store=default) from URL’s in Magento
You may have noticed that even when you have ‘add store code to URL’s’ set in Magento’s system configuration set to ‘No’, when you insert a link into the HTML editor via Magento’s widget, it will/can often still add ?___store=default to the end of URL’s.
There’s a quick and simple fix by extending the Mage core.
Copy
app/code/core/Mage/Catalog/Block/Widget/Link.php
to…
app/code/local/Mage/Catalog/Block/Widget/Link.php
Search for… (line 91 in Magento 1.7.x)
$this->_href = $this->_href . $symbol . "___store=" . $store->getCode();
And modify to…
$this->_href = $this->_href;
Upload and save your changes and you’ll now not have your widget (dynamically) inserted links getting appended with ?___store=default.
not working. please help.
How is it not working Renish?
Geoff,
Worked perfectly for me on 1.7.02.
Thanks…..
Glad it helped Eddie…
Thanks for the info, but it doenst work for me…
I have magento 1.7.0.2, your solution dont break anything, just i get the /?___from_store=en like before i touched the code.
What am i doing wrong?
Thanks for your help!!
Sorry to hear it hasn’t worked for you Shirakat.
Can you double check you have the correct path replicated in your local code pool?
It has to be exactly like below otherwise it won’t extend the core Mage file and no change will take affect…
app/code/local/Mage/Catalog/Block/Widget/Link.php
Failing that, have you tried clearing your cache and reindexing in Magento?
Worked perfectly for me on 1.9.0.1
Actually, you have to set ‘add store code to URL’s’ set in Magento’s system configuration set to ‘YES’,
NO = add ?___store=default for all switches
YES adds the store code into every URL
magento gui also says “IN URLS”
“Warning! When using Store Code in URLs, in some cases system may not work properly if URLs without Store Codes are specified in the third party services (e.g. PayPal etc.).”
Thanks for your comment Center.
When ‘Add Store Code to Urls’ is set to ‘Yes’, it adds an extra path into the URL with the store code, like:-
domain.com/store_code/category/etc
When this is set to ‘No’, it’s like:-
domain.com/category/etc
It doesn’t actually affect the appended switch parameter to the URL.
Hello! Please tell me how to do it for magento 1.9?
Exactly the same for Magento 1.9.X too Sergey.
Unfortunately did not work …:-(I did not have the folder “local”. I created it and put it in the folder as you have written. app/code/local/Mage/Catalog/Block/Widget/Link.php In this file, replace the line.
Yes, you will need to replicate the path in your ‘local’ code pool if it doesn’t already exist. Feel free to share the URL of where this is problem is apparent if you’re still having an issue.
I created a folder, as you have written. Here’s shop where I train.:-) http://agestor.ru/
Hey Sergey, where on your store can we find a URL with ?___store=default? I couldn’t see any, does this mean you managed to resolve the problem in the end?
Please help, I can not find a solution …
Perfect solution! It works like a charm! Thank you! Do you want to create a module instead? I really hate Mage override (only for temporary approach)
Hey Jackey, it would be a good idea to package this as a small extension and extend the class properly. It’s unlikely I will get a chance to look at this in the next month or two though as I am so busy but will try and pick this back up again later down the line (feel free to remind me). Thanks.
Hello, i need help.
its not working for me.
i have 3 language on the website:
Hebrew (default), English and Arabic.
actually i need the default url will show without store code, but for the “en” and for the “ar” that will show the code store, because i want to create “sitemap” for each store, and also with code store i have the option to redirect the customers for the specific language they need.
do you have any solution for me?
Thx.
Hey Yechiel, sorry for such a delayed reply.
Magento uses this URL parameter for switching between languages, are you wanting to remove the parameter that looks like this
&___from_store=default
from your URL’s?There is an extra step for working with the URL parameters when serving your website content in multiple languages in Magento.
Looking at your website, you managed to resolve it?
I can post a follow up to this with the extra steps for languages too.
Hey Geoff, it would be great to read the follow up you offered/mentioned in your above reply. I`m using the language switcher and trying to get the ?___store=default removed. But, even after hours of try and error, i can`t solve it. So, i`d like to read your suggestion.
Thanks.
Hi,
Thanks for this – worked on CE 1.9.2.2.
Best wishes,
Eddie
Excellent Eddie, thanks for stopping by and confirming.
hi, this solution did’t worked for me for site time when i opened the site in browser, but in 2nd time, its working fine. we are using this module : https://github.com/vovsky/Atwix_Ipstoreswitcher once i disable the module, its working fine.
Hi,
It did not work for me.
I created the file and changed as suggested.
mb.vijayatech.com
When I changed the file, My store View was set to Japnese by default, now it is coming as English.
Can you suggest me, what to correct?
Hey Viswa,
Thanks for stopping by.
What version of Magento are you running and did you clear your store cache after making the change?