/** * Function called before all process */ protected function beforeExecute() { parent::beforeExecute(); $this->categoryNormalizer = $this->normalizerGuesser->getCategoryNormalizer($this->getClientParameters()); $magentoStoreViews = $this->webservice->getStoreViewsList(); $magentoCategories = $this->webservice->getCategoriesStatus(); $this->globalContext = array_merge($this->globalContext, ['magentoCategories' => $magentoCategories, 'magentoUrl' => $this->getSoapUrl(), 'defaultLocale' => $this->defaultLocale, 'magentoStoreViews' => $magentoStoreViews, 'categoryMapping' => $this->categoryMappingMerger->getMapping(), 'defaultStoreView' => $this->getDefaultStoreView()]); }
/** * {@inheritdoc} */ public function read() { $attribute = parent::read(); $attributeMapping = $this->attributeCodeMappingMerger->getMapping(); while ($attribute !== null && $this->isAttributeIgnored($attribute, $attributeMapping)) { $attribute = parent::read(); } return $attribute; }
/** * {@inheritdoc} */ public function getMapping() { $magentoAttributeMappings = $this->attributeMappingManager->getAllMagentoAttribute($this->clientParameters->getSoapUrl()); $attributeCodeMapping = $this->attributeCodeMappingMerger->getMapping(); $mappingCollection = new MappingCollection(); foreach ($magentoAttributeMappings as $magentoAttributeMapping) { $pimAttributeCode = $magentoAttributeMapping->getAttribute()->getCode(); $mappingCollection->add(['source' => $attributeCodeMapping->getTarget($pimAttributeCode), 'target' => $magentoAttributeMapping->getMagentoAttributeId(), 'deletable' => true]); } return $mappingCollection; }
/** * Clean the given attribute. * * @param array $attribute * @param array $magentoAttributes */ protected function cleanAttribute(array $attribute, array $magentoAttributes) { $magentoAttributeCode = $attribute['code']; $pimAttributeCode = $this->attributeCodeMappingMerger->getMapping()->getSource($magentoAttributeCode); $pimAttribute = $this->getAttribute($pimAttributeCode); if (!in_array($attribute['code'], $this->getIgnoredAttributes()) && ($pimAttributeCode == null || (!$pimAttribute || $pimAttribute && !$pimAttribute->getFamilies()))) { try { $this->handleAttributeNotInPimAnymore($attribute); } catch (SoapCallException $e) { throw new InvalidItemException($e->getMessage(), [$attribute['code']]); } } }
/** * Function called before all process */ protected function beforeExecute() { parent::beforeExecute(); $this->globalContext['defaultLocale'] = $this->defaultLocale; $this->globalContext['storeViewMapping'] = $this->storeViewMappingMerger->getMapping(); $this->globalContext['defaultStoreView'] = $this->getDefaultStoreView(); }
/** * Function called before all process */ protected function beforeExecute() { parent::beforeExecute(); $this->productNormalizer = $this->normalizerGuesser->getProductNormalizer($this->getClientParameters(), $this->enabled, $this->visibility, $this->currency); $magentoStoreViews = $this->webservice->getStoreViewsList(); $magentoAttributes = $this->webservice->getAllAttributes(); $magentoAttributesOptions = $this->webservice->getAllAttributesOptions(); $this->globalContext = array_merge($this->globalContext, ['channel' => $this->channel, 'website' => $this->website, 'magentoAttributes' => $magentoAttributes, 'magentoAttributesOptions' => $magentoAttributesOptions, 'magentoStoreViews' => $magentoStoreViews, 'categoryMapping' => $this->categoryMappingMerger->getMapping(), 'attributeCodeMapping' => $this->attributeMappingMerger->getMapping()]); }
/** * Verify if the magento attribute id is null else add the attribute to the attribute set. * * @param integer $magentoAttributeId * @param AbstractAttribute $pimAttribute */ protected function manageAttributeSet($magentoAttributeId, $pimAttribute) { if ($this->attributeIdMappingMerger->getMapping()->getSource($magentoAttributeId) != $pimAttribute->getCode()) { $this->addAttributeToAttributeSet($magentoAttributeId, $pimAttribute); } }
/** * Test if an attribute exist on magento * @param AbstractAttribute $attribute * @param array $magentoAttributes * * @return boolean */ protected function magentoAttributeExists(AbstractAttribute $attribute, array $magentoAttributes) { return array_key_exists(strtolower($this->attributeMappingMerger->getMapping()->getTarget($attribute->getCode())), $magentoAttributes); }