/**
  * Handle family creation.
  *
  * @param array $item
  *
  * @throws InvalidItemException
  */
 protected function handleNewFamily(array $item)
 {
     if (isset($item['families_to_create'])) {
         $pimFamily = $item['family_object'];
         $prestashopFamilyId = $this->webservice->createAttributeSet($item['families_to_create']['attributeSetName']);
         $prestashopUrl = $this->getPrestashopUrl();
         $this->familyMappingManager->registerFamilyMapping($pimFamily, $prestashopFamilyId, $prestashopUrl);
         $this->stepExecution->incrementSummaryInfo('family_created');
     }
 }
 /**
  * @param Family $family
  *
  * @return array
  */
 public function getAllSources(Family $family = null)
 {
     $sources = [];
     if ($this->isValid()) {
         $families = $this->familyManager->getFamilies();
         foreach ($families as $family) {
             $sources[] = ['id' => $family->getCode(), 'name' => $family->getCode()];
         }
     }
     return $sources;
 }
 /**
  * Handle deletion of families that are not in PIM anymore.
  *
  * @param string $name
  * @param int    $id
  *
  * @throws InvalidItemException
  */
 protected function handleFamilyNotInPimAnymore($name, $id)
 {
     if ($this->notInPimAnymoreAction === self::DELETE && !$this->familyMappingManager->prestashopFamilyExists($id, $this->getPrestashopUrl()) && !in_array($name, $this->getIgnoredFamilies())) {
         try {
             $this->webservice->removeAttributeSet($id, $this->forceAttributeSetRemoval);
             $this->stepExecution->incrementSummaryInfo('family_deleted');
         } catch (RestCallException $e) {
             throw new InvalidItemException($e->getMessage(), [$id], [$e]);
         }
     }
 }
 /**
  * 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;
                 }
             }
         }
     }
 }