[-] Core: Group::getCurrent() return the default customer group of the shop if default customer group is not associated to shop

This commit is contained in:
Rémi Gaillard committed 2013-11-12 18:49:52 +01:00
1 parent 6d7e2055ce
commit 75df12dd94
1 file changed
+10 -1
+10 -1
View File
@@ -305,12 +305,21 @@ class GroupCore extends ObjectModel
public static function getCurrent() public static function getCurrent()
{ {
static $groups = array(); static $groups = array();
$customer = Context::getContext()->customer; $customer = Context::getContext()->customer;
if (Validate::isLoadedObject($customer)) if (Validate::isLoadedObject($customer))
{
$id_group = (int)$customer->id_default_group; $id_group = (int)$customer->id_default_group;
$group = new Group((int)$id_group);
if (!$group->isAssociatedToShop(Context::getContext()->shop->id))
$group = new Group((int)Configuration::get('PS_CUSTOMER_GROUP'));
}
else else
$id_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP'); $id_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP');
if (!isset($groups[$id_group]) && isset($group))
$groups[$id_group] = $group;
if (!isset($groups[$id_group])) if (!isset($groups[$id_group]))
$groups[$id_group] = new Group($id_group); $groups[$id_group] = new Group($id_group);