/** * {@inheritdoc} */ public function execute() { parent::beforeExecute(); $magentoCategories = $this->webservice->getCategoriesStatus(); foreach ($magentoCategories as $category) { if (!$this->categoryMappingManager->magentoCategoryExists($category['category_id'], $this->getSoapUrl()) && !($category['level'] === '0' || $category['level'] === '1')) { try { $this->handleCategoryNotInPimAnymore($category); } catch (SoapCallException $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']; $magentoCategoryId = $this->categoryMappingManager->getIdFromCategory($pimCategory, $this->getSoapUrl()); $magentoCategory = $variationCategory['magentoCategory']; $magentoCategory[0] = $magentoCategoryId; $this->webservice->sendUpdateCategory($magentoCategory); $this->stepExecution->incrementSummaryInfo(self::CATEGORY_TRANSLATION_SENT); } } }
/** * Test if the category has moved on magento side. * * @param CategoryInterface $category * @param array $context * * @return boolean */ protected function categoryHasMoved(CategoryInterface $category, $context) { $currentCategoryId = $this->getMagentoCategoryId($category, $context['magentoUrl']); $currentParentId = $this->categoryMappingManager->getIdFromCategory($category->getParent(), $context['magentoUrl'], $context['categoryMapping']); return isset($context['magentoCategories'][$currentCategoryId]) ? $context['magentoCategories'][$currentCategoryId]['parent_id'] !== $currentParentId : true; }