/**
  * {@inheritdoc}
  */
 public function get($groupId)
 {
     /** @var \Magento\Catalog\Model\Product\Attribute\Group $group */
     $group = $this->groupFactory->create();
     $this->groupResource->load($group, $groupId);
     if (!$group->getId()) {
         throw new NoSuchEntityException(__('Group with id "%1" does not exist.', $groupId));
     }
     return $group;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function delete($attributeSetId, $groupId)
 {
     /** @var Group $attributeGroup */
     $attributeGroup = $this->groupFactory->create();
     $attributeGroup->load($groupId);
     if (!$attributeGroup->getId()) {
         throw NoSuchEntityException::singleField('attributeGroupId', $groupId);
     }
     if ($attributeGroup->hasSystemAttributes()) {
         throw new StateException('Attribute group that contains system attributes can not be deleted');
     }
     if ($attributeGroup->getAttributeSetId() != $attributeSetId) {
         throw new StateException('Attribute group does not belong to provided attribute set');
     }
     $attributeGroup->delete();
     return true;
 }