隐藏Magento参数


Hide Magento parameters

我的magento网站上有不同的语言(不同的商店)当我切换语言时,我会在url中获得参数(在开始页,在子域名上是可以的)

所以我得到了这个:

?___store=default&___from_store=english

我尝试在

中编辑
app / code / local / Mage / Core / Store.php

languages.phtml

您需要在系统->配置->Web的URL选项中将"Add Store Code to Urls"设置为Yes。同时将"使用Web服务器重写"设置为YES。

然后替换/template/page/switch/languages中的所有代码。php,代码如下:

<?php if(count($this->getStores())>1): ?>
<?php
$stores = array();
$_current = null;
foreach ($this->getStores() as $_lang) {
$_selected = $_selected_option = '';
if ( ($_lang->getId() == $this->getCurrentStoreId()) ) {
    $_current =  $_lang;
}
}
?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
<?php foreach ($this->getStores() as $_lang): ?>
    <?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
    <option value="<?php echo $_lang->getCurrentUrl(false); ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>

它将显示如下url: http://yourdomain.com/en或http://yourdomain.com/fr(无论您提到的商店视图代码)

我在

app / code / local / Mage / Core / Model / Store.php

函数getCurrentUrl()

第1160行

return $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host']. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '') 
. $storeParsedUrl['path'] . $requestString . ($storeParsedQuery ? '?'.http_build_query($storeParsedQuery, '', '&') : '');

改变

return $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host'] . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path'] . $requestString;