Jump to content

getGroupsStatic always says group is visitor


GS VISION

Recommended Posts

Hello, I have to do some limitations dependant of customer group and as it is not defined in smarty at category controller I had to include it myself so I can do my checkups. What I did was use the Customer getGroupsStatic() method which gets the groups of the user and puts them into an array

public static function getGroupsStatic($id_customer)
	{
		if (!Group::isFeatureActive())
			return array(Configuration::get('PS_CUSTOMER_GROUP'));

		if ($id_customer == 0)
			self::$_customer_groups[$id_customer] = array((int)Configuration::get('PS_UNIDENTIFIED_GROUP'));

		if (!isset(self::$_customer_groups[$id_customer]))
		{
			self::$_customer_groups[$id_customer] = array();
			$result = Db::getInstance()->executeS('
			SELECT cg.`id_group`
			FROM '._DB_PREFIX_.'customer_group cg
			WHERE cg.`id_customer` = '.(int)$id_customer);
			foreach ($result as $group)
				self::$_customer_groups[$id_customer][] = (int)$group['id_group'];
		}
		return self::$_customer_groups[$id_customer];
	}

The problem is it always gives me the customer is visitor (array has only one member which says customer group is 3). I tried the query on the database and it is correct, so something else is modifing it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...