From 3975599023e1922b80274d951794afdb61a137ac Mon Sep 17 00:00:00 2001 From: gRoussac Date: Thu, 5 Dec 2013 16:47:05 +0100 Subject: [PATCH] =?UTF-8?q?[-=C2=A0]=20CORE=20:=20Fix=20bug=20#PSCFV-10627?= =?UTF-8?q?,=20bad=20default=20shoip=20currency=20&&=20Shop::getEntityIds?= =?UTF-8?q?=20returning=20deleted=20currency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Tools.php | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index 849b1db65..107e7ff0b 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -421,28 +421,27 @@ class ToolsCore if (is_object($currency) && $currency->id && !$currency->deleted && $currency->isAssociatedToShop()) $cookie->id_currency = (int)$currency->id; } - - if ((int)$cookie->id_currency) - { - $currency = Currency::getCurrencyInstance((int)$cookie->id_currency); - if (is_object($currency) && (int)$currency->id && (int)$currency->deleted != 1 && $currency->active) - if ($currency->isAssociatedToShop()) - return $currency; - else - { - // get currency from context - $currency = Shop::getEntityIds('currency', Context::getContext()->shop->id); - if (isset($currency[0]) && $currency[0]['id_currency']) - { - $cookie->id_currency = $currency[0]['id_currency']; - return Currency::getCurrencyInstance((int)$cookie->id_currency); - } - } - } + $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT')); - if (is_object($currency) && $currency->id) - $cookie->id_currency = (int)$currency->id; + if ((int)$cookie->id_currency) + $currency = Currency::getCurrencyInstance((int)$cookie->id_currency); + if (is_object($currency) && (int)$currency->id && (int)$currency->deleted != 1 && $currency->active) + { + $cookie->id_currency = (int)$currency->id; + if ($currency->isAssociatedToShop()) + return $currency; + else + { + // get currency from context + $currency = Shop::getEntityIds('currency', Context::getContext()->shop->id, true, true); + if (isset($currency[0]) && $currency[0]['id_currency']) + { + $cookie->id_currency = $currency[0]['id_currency']; + return Currency::getCurrencyInstance((int)$cookie->id_currency); + } + } + } return $currency; }