【发布时间】:2014-08-11 06:48:36
【问题描述】:
我正在 magento 的产品列表页面上按价格范围功能实现自定义过滤器
我有多种货币商店,基础货币是 INR ,其他 6 到 7 种货币
我从价格范围中获取输入并在产品集合中使用以下过滤器
$this->_productCollection = $layer->getProductCollection();
if($this->getRequest()->getParam('filterPrice')){
$baseCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
$currentCurrency = Mage::app()->getStore()->getCurrentCurrencyCode();
$price = explode('-',$this->getRequest()->getParam('filterPrice'));
$min = str_replace(Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(),'',$price[0]);
$min = $this->currencyConverter($min, $currentCurrency, $baseCurrency);
$max = str_replace(Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(),'',$price[1]);
$max = $this->currencyConverter($max, $currentCurrency, $baseCurrency);
$this->_productCollection->addAttributeToFilter('price',array('from'=>$min,'to'=>$max));
}
currencyConverter 函数在哪里
public function currencyConverter($amount,$from,$to)
{
if($from!=$to){
$targetCurrency = Mage::getModel('directory/currency')->load($to);
$price = Mage::helper('directory')->currencyConvert($amount, $from, $targetCurrency);
$converted_final_price = Mage::app()->getStore()->roundPrice($price);
return $converted_final_price;
}else{
return $amount;
}
}
但我收到以下错误
来自“CAD-INR”的未定义汇率。
从其他线程,我知道我需要从 magento 后端设置货币和汇率,并且我实现了相同的,但错误仍然相同。
【问题讨论】: