Arash Rabiee
Arash Rabiee

Reputation: 1099

How to add new customer group programmatically, in Prestashop 1.6

I'm creating a module, which needs a new customer group, and I want to do it programmatically.

I looked at controllers/admin/AdminGroupsController.php there is nothing useful there, and there is a method by name of addGroups in classes/Customer.php and this one is not able to do what I want.

So, I would be thankful if someone help me.

Upvotes: 0

Views: 1042

Answers (1)

defuzed
defuzed

Reputation: 568

You can just use normal object creation of the Group class. Something like this:

$group = new Group();
$group->name = array(Configuration::get('PS_LANG_DEFAULT') => '[whatever]');
$group->price_display_method = [0 or 1];
$group->add();

should work. You can look at the Group class to see what the other properties are called and what their type is.

Upvotes: 2

Related Questions