/**
  * {@inheritdoc}
  */
 public function execute()
 {
     parent::beforeExecute();
     $prestashopCategories = $this->webservice->getCategoriesStatus();
     foreach ($prestashopCategories as $category) {
         if (!$this->categoryMappingManager->prestashopCategoryExists($category['category_id'], $this->getPrestashopUrl()) && !($category['level'] === '0' || $category['level'] === '1')) {
             try {
                 $this->handleCategoryNotInPimAnymore($category);
             } catch (RestCallException $e) {
                 throw new InvalidItemException($e->getMessage(), [json_encode($category)]);
             }
         }
     }
 }
 /**
  * Handle category variation update.
  *
  * @param array $batch
  */
 protected function handleVariationCategory(array $batch)
 {
     if (isset($batch['variation'])) {
         foreach ($batch['variation'] as $variationCategory) {
             $pimCategory = $variationCategory['pimCategory'];
             $prestashopCategoryId = $this->categoryMappingManager->getIdFromCategory($pimCategory, $this->getPrestashopUrl());
             $prestashopCategory = $variationCategory['prestashopCategory'];
             $prestashopCategory[0] = $prestashopCategoryId;
             $this->webservice->sendUpdateCategory($prestashopCategory);
             $this->stepExecution->incrementSummaryInfo('category_translation_sent');
         }
     }
 }
 /**
  * Test if the category has moved on prestashop side.
  *
  * @param CategoryInterface $category
  * @param array             $context
  *
  * @return boolean
  */
 protected function categoryHasMoved(CategoryInterface $category, $context)
 {
     $currentCategoryId = $this->getPrestashopCategoryId($category, $context['prestashopUrl']);
     $currentParentId = $this->categoryMappingManager->getIdFromCategory($category->getParent(), $context['prestashopUrl'], $context['categoryMapping']);
     return isset($context['prestashopCategories'][$currentCategoryId]) ? $context['prestashopCategories'][$currentCategoryId]['parent_id'] !== $currentParentId : true;
 }