Aimeos\ShopBundle\Command\AccountCommand::getGroupItem PHP Method

getGroupItem() protected method

Returns the customer group item for the given code
protected getGroupItem ( Aimeos\MShop\Context\Item\Iface $context, string $code ) : Aimeos\MShop\Customer\Item\Group\Iface
$context Aimeos\MShop\Context\Item\Iface Aimeos context object
$code string Unique customer group code
return Aimeos\MShop\Customer\Item\Group\Iface Aimeos customer group item object
    protected function getGroupItem(\Aimeos\MShop\Context\Item\Iface $context, $code)
    {
        $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('group');
        try {
            $item = $manager->findItem($code);
        } catch (\Aimeos\MShop\Exception $e) {
            $item = $manager->createItem();
            $item->setLabel($code);
            $item->setCode($code);
            $manager->saveItem($item);
        }
        return $item;
    }