2
votes

I'm currently working on a few modules connected to a ERP system. The ERP manages pretty much everything (customers, products, orders, order status...) but I'm having a bit of a hard time with the customer groups. I want to be able to add and update those same groups threw a module. Does anyone have any insight on this? Will I have to override the core class?

1
I can create a module so you can add and update customer group. let me know. - ravi2432
@ravi2432 I appreciate that but I'm more looking for to learn how to do it then having it handed to me. I'll need to maintain it and improve it as the time goes. But if you by any chance have some snippets that could help me start or just give me an idea of what classes I'll be using then I would be gratefull. - MacJ
Please do not use tag group. It is to be deleted in future as too vague. - Vadim Kotov

1 Answers

3
votes

Here is the solution to my own question. Feel free to write me in case you have questions.

private function validateGroup($group_name)
{
    $group = new Group();
    return $validation = $group->searchByName($group_name);
}

public function addGroup($groups)
{
    $new_group = new Group();


    foreach ($groups as $group) {
        $new_group->name                    = $group->name;
        $new_group->price_display_method    = 1; //0 - Doesn't display price   1 - Display price

        if (!$authentication = $this->validateGroup($group->name)) {
            $new_group->add();
        } else {
            $new_group->update();
        }
    }
}

Cheers