I use Magento ver. 1.8.1.0 and when I go one my website I've got this error:
Fatal error: Call to a member function getCode() on a non-object in app/code/core/Mage/Directory/Model/Currency.php on line 193
When I choose USD for currency in Configuration -> Currency setting, it's ok, but after, with my payment method it doesn't work because it need CHF (Swiss franc) so if I choose CHF for Currency I have the Fatal error for all the website...
On line 194 I have this function:
public function convert($price, $toCurrency = null)
{
if (is_null($toCurrency)) {
return $price;
} else {
$rate = $this->getRate($toCurrency);
if ($rate) {
return $price * $rate;
}
}
throw new Exception(Mage::helper('directory')->__('Undefined rate from "%s-%s".', $this->getCode(),$toCurrency->getCode()));
}
and the getCode() function:
/**
* Get currency code
*
* @return string
*/
public function getCode()
{
return $this->_getData('currency_code');
}
I don't know what is wrong, somebody can help me? Thank you