1

A question that one would expect to find the answer to... But except for cron settings etcetera I can't find it.

Question: "How to import currency rates via shell"?

1

Yes,Can do this by create a shell php and include Mage.php at first line of code. Then create an array which is included the rate in below formatand using Mage::getModel('directory/currency')->saveRates($rate); update the currency rate.

See At: http://blog.chapagain.com.np/magento-get-currency-code-currency-rate/

CODE & FORMAT:

$rate=array();
$rate[BASE_CURRENCY_CODE][YOUR_CURRENCY_CODE]=YOUR_CURRENCY_RATE_INR;
Mage::getModel('directory/currency')->saveRates($rate);

EXAMPLE:

$rate=array();
$rate[USD][INR]=62.0924;
$rate[USD][HKD]=7.502;
$rate[USD][USD]=1.00;
Mage::getModel('directory/currency')->saveRates($rate);

Shell Code:

require_once 'YOUR_MAGENTODIR/app/Mage.php';
Mage::app('admin');
$currencyModel = Mage::getModel('directory/currency');
$currencies = $currencyModel->getConfigAllowCurrencies();
$defaultCurrencies = $currencyModel->getConfigBaseCurrencies();
$rate=array();
foreach( $currencies as $key => $value ) {
 $rate[$defaultCurrencies[0]][$value]='YourRate';
}
Mage::getModel('directory/currency')->saveRates($rate);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.