Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory currency - performance optimalization #1252

Merged
24 changes: 15 additions & 9 deletions app/code/core/Mage/Directory/Model/Resource/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,22 @@ public function saveRates($rates)
*/
public function getConfigCurrencies($model, $path)
{
$adapter = $this->_getReadAdapter();
$bind = array(':config_path' => $path);
$select = $adapter->select()
->from($this->getTable('core/config_data'))
->where('path = :config_path');
$result = array();
$rowSet = $adapter->fetchAll($select, $bind);
foreach ($rowSet as $row) {
$result = array_merge($result, explode(',', $row['value']));
$result = [];
$config = Mage::app()->getConfig();

// default
$result = array_merge($result, explode(',', trim($config->getNode($path, 'default'))));

// stores
foreach (Mage::app()->getStores(true) as $store) {
$result = array_merge($result, explode(',', trim($config->getNode($path, 'stores', $store->getCode()))));
}

// websites
foreach (Mage::app()->getWebsites(true) as $website) {
$result = array_merge($result, explode(',', trim($config->getNode($path, 'websites', $website->getCode()))));
}

sort($result);

return array_unique($result);
Expand Down