Skip to content

Instantly share code, notes, and snippets.

@tawfekov
Last active December 30, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tawfekov/7769595 to your computer and use it in GitHub Desktop.
Save tawfekov/7769595 to your computer and use it in GitHub Desktop.
update magento currency via cron or simple php script
<?php
include("app/Mage.php");
Mage::app();
$now = new \DateTime();
echo "start downloading rates : {$now->format("Y-m-d H:i:s")}\n";
$model = Mage::getModel("directory/currency");
$currency_converter= Mage::getModel("directory/currency_import_webservicex");
$rates = $currency_converter->fetchRates();
echo json_encode($rates) . "\n";
echo "has been downloaded\n";
echo "start saving rates to db \n";
$model->saveRates($rates);
$finished = new \DateTime();
echo "finsihed saving rates to db on : {$finished->format("Y-m-d H:i:s")} \n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment