예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function getList($attributeSetId)
 {
     if (!$this->attributeSetFactory->create()->load($attributeSetId)->getId()) {
         throw NoSuchEntityException::singleField('attributeSetId', $attributeSetId);
     }
     $collection = $this->groupListFactory->create();
     $collection->setAttributeSetFilter($attributeSetId);
     $collection->setSortOrder();
     $groups = array();
     /** @var $group \Magento\Eav\Model\Entity\Attribute\Group */
     foreach ($collection->getItems() as $group) {
         $this->groupBuilder->setId($group->getId())->setName($group->getAttributeGroupName());
         $groups[] = $this->groupBuilder->create();
     }
     return $groups;
 }
예제 #2
0
 /**
  * {inheritdoc}
  */
 public function create($attributeSetId, \Magento\Catalog\Service\V1\Data\Eav\AttributeGroup $groupData)
 {
     if (!$this->setFactory->create()->load($attributeSetId)->getId()) {
         throw NoSuchEntityException::singleField('attributeSetId', $attributeSetId);
     }
     try {
         /** @var Group $attributeGroup */
         $attributeGroup = $this->groupFactory->create();
         $attributeGroup->setAttributeGroupName($groupData->getName());
         $attributeGroup->setAttributeSetId($attributeSetId);
         $attributeGroup->save();
         return $this->groupBuilder->setId($attributeGroup->getId())->setName($attributeGroup->getAttributeGroupName())->create();
     } catch (\Exception $e) {
         throw new CouldNotSaveException('Could not create attribute group. Maybe group with such name already exists');
     }
 }