In magento, I am using two store views one is for arabic and another one is english language. When I am switching the store to english this string is appended in url (___store=english) for english store view.like wise for arabic. Now I want to remove the ?___store=english for english and ?___store=arabic for arabic in URL.
问题:
回答1:
If using the link widget, use the following process.
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 / line 100 in Magento 1.9.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.
Credit: DesignHaven
回答2:
To remove this format: ?___store=english for english and ?___store=arabic
In the design file find the languages.phtml
/app/design/frontend/default/template/page/switch/languages.phtml
In the line 41
echo $_lang->getCurrentUrl()
Add 'false' as parameter
echo $_lang->getCurrentUrl(false)
Actual Url:
http:example.com?___store=english for english and ?___store=arabic
After added the false parameter in $_lang->getCurrentUrl(false) method. Url will be generated like the below
http:example.com?___store=english
Then to remove the '___store=english' parameter you need to add a pre dispatch event in the controller action: Add this code in your local module config.xml
<controller_action_predispatch>
<observers>
<controller_action_before>
<class>marketplace/observer</class>
<method>setToControllerActionPreDispatch</method>
</controller_action_before>
</observers>
</controller_action_predispatch>
Add this method in your local observer
public function setToControllerActionPreDispatch($observer)
{
$pathInfo = Mage::helper('core/url')->getCurrentUrl();
if(strpos($pathInfo, "___store") != ''){
$pathInfo = str_replace(array('?___store=arabic', '?___store=default'), '' , $pathInfo);
Mage::app()->getResponse()->setRedirect($pathInfo);
}
}
回答3:
In admin got to System > Configuration (from the top menu), then go to 'Web' form the left menu.
The first option is 'Add Store Code to Urls', set this to no.
回答4:
After looking at this and experimenting in the admin, my thought is to consider multiple Magento 'websites' instead of stores. It seems even if you exclude the query parameter, Magento wants to append the store name as the first component of the URI. In short, I'm not sure how good an idea it is to try and actually remove the store component from the URL when using multiple 'stores'.
回答5:
To remove this format: ?___store=english for english
Step 1 : Go to system->Configuration. Then go to web tab. You can see there is an option ' "Add Store Code to Urls" set that option to "Yes"
Step 2 : /app/design/frontend/base/default/template/page/switch/languages.phtml find this below code :
echo $_lang->getCurrentUrl()
Add 'false' as parameter
echo $_lang->getCurrentUrl(false)
Step 3 : Copy app/code/core/Mage/Catalog/Block/Widget/Link.php to app/code/local/Mage/Catalog/Block/Widget/Link.php
Search this line :
$this->_href = $this->_href . $symbol . "___store=" . $store->getCode();
And modify to :
$this->_href = $this->_href;
Step 4 : Go to Admin panel locate navigation system->Index Management >> Reindex Data
回答6:
I know the question is old, but if anybody needs this functionality yet and you do not want to change any files I forked module on Github and added some improvements.
You can also use composer to install it.