0
我有一個Magento貨幣的問題:我的代碼工作正常,否則,現在我想在貨幣更改後重定向頁面。Magento設置多種貨幣
假設我目前的網址爲http://www.example.com/women/?color=black
。
現在,當我更改貨幣時,它將重定向到:http://www.example.com/women/
;所以它刪除了?color=black
。
代碼:
if($this->getCurrencyCount()>1): ?>
<div class="block block-currency">
<div class="block-title">
<strong><span><?php echo $this->__('Select Your Currency') ?></span></strong>
</div>
<div class="block-content">
<select name="currency" title="<?php echo $this->__('Select Your Currency') ?>" onchange="setLocation(this.value)">
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
<option value="<?php echo $this->getSwitchCurrencyUrl($_code) ?>"<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected="selected"<?php endif; ?>>
<?php echo $_name ?> - <?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php endif;
更新的代碼:
<?PHP $currentParams = $this->getRequest()->getParams(); ?>
<div style="float:left; margin-top:10px; color:#727478;">
<!--Change 1 to 0 if you wish to output selector always-->
<?php if($this->getCurrencyCount() > 1): ?>
<span>Select Currency:</span>
<select name="custom-currency-selector" id="custom-currency-selector">
<?php foreach ($this->getCurrencies() as $_code => $_name):
$currencyUrl = $this->getSwitchCurrencyUrl($_code);
foreach ($currentParams as $_param) {
$currencyUrl = $this->helper('core/url')->addRequestParam($currencyUrl, $_param);
}
?>
<option value="<?php echo $currencyUrl; ?>"
<?php if($_code == $this->getCurrentCurrencyCode()): ?>
selected="SELECTED"
<?php endif; ?>>
<?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
<?php endif;?>
更新的代碼:
<!--Change 1 to 0 if you wish to output selector always-->
<?php if($this->getCurrencyCount() > 1):
$currentParams = $this->getRequest()->getParams();
?>
<span>Select Currency:</span>
<select name="custom-currency-selector" id="custom-currency-selector">
<?php foreach ($this->getCurrencies() as $_code => $_name):
$currencyUrl = $this->helper('core/url')->addRequestParam($this->getSwitchCurrencyUrl($_code),$currentParams)
?>
<option value="<?php echo $currencyUrl ?>"
<?php if($_code == $this->getCurrentCurrencyCode()): ?>
selected="SELECTED"
<?php endif; ?>>
<?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
<?php endif; ?>
仍然是同樣的問題.. –
也許你在錯誤的地方使用它。在我提出的一段代碼之後,什麼網址包含$ currencyUrl? –
讓我用新代碼更新我的問題。 –