/** * {@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() { $prestashopAttributeMappings = $this->attributeMappingManager->getAllPrestashopAttribute($this->clientParameters->getPrestashopUrl()); $attributeCodeMapping = $this->attributeCodeMappingMerger->getMapping(); $mappingCollection = new MappingCollection(); foreach ($prestashopAttributeMappings as $prestashopAttributeMapping) { $pimAttributeCode = $prestashopAttributeMapping->getAttribute()->getCode(); $mappingCollection->add(['source' => $attributeCodeMapping->getTarget($pimAttributeCode), 'target' => $prestashopAttributeMapping->getPrestashopAttributeId(), 'deletable' => true]); } return $mappingCollection; }
/** * Clean the given attribute. * * @param array $attribute * @param array $prestashopAttributes */ protected function cleanAttribute(array $attribute, array $prestashopAttributes) { $prestashopAttributeCode = $attribute['code']; $pimAttributeCode = $this->attributeCodeMappingMerger->getMapping()->getSource($prestashopAttributeCode); $pimAttribute = $this->getAttribute($pimAttributeCode); if (!in_array($attribute['code'], $this->getIgnoredAttributes()) && ($pimAttributeCode == null || (!$pimAttribute || $pimAttribute && !$pimAttribute->getFamilies()))) { try { $this->handleAttributeNotInPimAnymore($attribute); } catch (RestCallException $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->categoryNormalizer = $this->normalizerGuesser->getCategoryNormalizer($this->getClientParameters()); $prestashopStoreViews = $this->webservice->getStoreViewsList(); $prestashopCategories = $this->webservice->getCategoriesStatus(); $this->globalContext = array_merge($this->globalContext, ['prestashopCategories' => $prestashopCategories, 'prestashopUrl' => $this->getPrestashopUrl(), 'defaultLocale' => $this->defaultLocale, 'prestashopStoreViews' => $prestashopStoreViews, 'categoryMapping' => $this->categoryMappingMerger->getMapping(), 'defaultStoreView' => $this->getDefaultStoreView(), 'is_anchor' => $this->isAnchor, 'urlKey' => $this->urlKey]); }
/** * Function called before all process. */ protected function beforeExecute() { parent::beforeExecute(); $this->productNormalizer = $this->normalizerGuesser->getProductNormalizer($this->getClientParameters(), $this->enabled, $this->visibility, $this->variantMemberVisibility, $this->currency); $prestashopStoreViews = $this->webservice->getStoreViewsList(); $prestashopAttributes = $this->webservice->getAllAttributes(); $prestashopAttributesOptions = $this->webservice->getAllAttributesOptions(); $this->globalContext = array_merge($this->globalContext, ['channel' => $this->channel, 'website' => $this->website, 'prestashopAttributes' => $prestashopAttributes, 'prestashopAttributesOptions' => $prestashopAttributesOptions, 'prestashopStoreViews' => $prestashopStoreViews, 'categoryMapping' => $this->categoryMappingMerger->getMapping(), 'attributeCodeMapping' => $this->attributeMappingMerger->getMapping(), 'smallImageAttribute' => $this->smallImageAttribute, 'baseImageAttribute' => $this->baseImageAttribute, 'thumbnailAttribute' => $this->thumbnailAttribute, 'urlKey' => $this->urlKey, 'skuFirst' => $this->skuFirst]); }
/** * Verify if the prestashop attribute id is null else add the attribute to the attribute set. * * @param integer $prestashopAttributeId * @param AbstractAttribute $pimAttribute */ protected function manageAttributeSet($prestashopAttributeId, $pimAttribute) { if ($this->attributeIdMappingMerger->getMapping()->getSource($prestashopAttributeId) != $pimAttribute->getCode()) { $this->addAttributeToAttributeSet($prestashopAttributeId, $pimAttribute); } }
/** * Test if an attribute exist on prestashop. * * @param AbstractAttribute $attribute * @param array $prestashopAttributes * * @return boolean */ protected function prestashopAttributeExists(AbstractAttribute $attribute, array $prestashopAttributes) { return array_key_exists(strtolower($this->attributeMappingMerger->getMapping()->getTarget($attribute->getCode())), $prestashopAttributes); }