[- ] CORE : Fix bug #PSCFV-10627, bad default shoip currency && Shop::getEntityIds returning deleted currency

This commit is contained in:
gRoussac
2013-12-05 16:47:05 +01:00
parent 9dd82367f3
commit 3975599023
+19 -20
View File
@@ -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;
}