/** * @param AttributeGroup $group * * @return array */ public function getAllSources(AttributeGroup $group = null) { $sources = []; if ($this->isValid()) { $groups = $this->attributeGroupManager->getAllGroups(); foreach ($groups as $group) { $sources[] = ['id' => $group->getCode(), 'name' => $group->getCode()]; } } return $sources; }
/** * Create a group in an attribute set. * * @param AbstractAttribute $pimAttribute * * @throws RestCallException */ protected function addGroupToAttributeSet(AbstractAttribute $pimAttribute) { $families = $pimAttribute->getFamilies(); $group = $pimAttribute->getGroup(); if (isset($group)) { $groupName = $group->getCode(); foreach ($families as $family) { $familyPrestashopId = $this->familyMappingManager->getIdFromFamily($family, $this->getPrestashopUrl()); if (null === $familyPrestashopId) { $prestashopAttributeSets = $this->webservice->getAttributeSetList(); if (array_key_exists($family->getCode(), $prestashopAttributeSets)) { $familyPrestashopId = $prestashopAttributeSets[$family->getCode()]; } } try { $prestashopGroupId = $this->webservice->addAttributeGroupToAttributeSet($familyPrestashopId, $groupName); $this->attributeGroupMappingManager->registerGroupMapping($group, $family, $prestashopGroupId, $this->getPrestashopUrl()); } catch (RestCallException $e) { if (static::SOAP_FAULT_GROUP_ALREADY_IN_SET === $e->getPrevious()->faultcode) { echo "DEBUG: Group " . $groupName . " already exists in attribute set " . $familyPrestashopId . "\n"; } else { throw $e; } } } } }