52 private $collectionProcessor;
79 $this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor();
88 $this->setRepository->get(
$group->getAttributeSetId());
93 if (
$group->getAttributeGroupId()) {
95 $existingGroup = $this->groupFactory->create();
96 $this->groupResource->load($existingGroup,
$group->getAttributeGroupId());
98 if (!$existingGroup->getId()) {
101 if ($existingGroup->getAttributeSetId() !=
$group->getAttributeSetId()) {
102 throw new StateException(
103 __(
"The attribute group doesn't belong to the provided attribute set.")
109 $this->groupResource->save(
$group);
110 }
catch (\Exception $e) {
111 throw new StateException(
__(
"The attributeGroup can't be saved."));
128 $searchResult = $this->searchResultsFactory->create();
131 $searchResult->setTotalCount(
$collection->getSize());
132 return $searchResult;
141 $group = $this->groupFactory->create();
144 throw new NoSuchEntityException(
145 __(
'The group with the "%1" ID doesn\'t exist. Verify the ID and try again.',
$groupId)
157 $this->groupResource->delete(
$group);
158 }
catch (\Exception $e) {
161 'The attribute group with id "%1" can\'t be deleted.',
190 foreach (
$group->getFilters() as $filter) {
191 if ($filter->getField() ==
'attribute_set_id') {
192 return $filter->getValue();
205 private function getCollectionProcessor()
207 if (!$this->collectionProcessor) {
209 'Magento\Eav\Model\Api\SearchCriteria\AttributeGroupCollectionProcessor' 212 return $this->collectionProcessor;
retrieveAttributeSetIdFromSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
static singleField($fieldName, $fieldValue)
save(\Magento\Eav\Api\Data\AttributeGroupInterface $group)
__construct(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Group $groupResource, \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory $groupListFactory, \Magento\Eav\Model\Entity\Attribute\GroupFactory $groupFactory, \Magento\Eav\Api\AttributeSetRepositoryInterface $setRepository, \Magento\Eav\Api\Data\AttributeGroupSearchResultsInterfaceFactory $searchResultsFactory, \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor, CollectionProcessorInterface $collectionProcessor=null)