コード例 #1
0
 /**
  * Get id from category and Prestashop url.
  *
  * @param CategoryInterface $category
  * @param string            $prestashopUrl
  * @param MappingCollection $categoryMapping
  *
  * @return int|null
  */
 public function getIdFromCategory(CategoryInterface $category, $prestashopUrl, MappingCollection $categoryMapping = null)
 {
     if ($categoryMapping && ($categoryId = $categoryMapping->getTarget($category->getCode())) != $category->getCode()) {
         return $categoryId;
     } else {
         $categoryMapping = $this->getEntityRepository()->findOneBy(['category' => $category, 'prestashopUrl' => $prestashopUrl]);
         return $categoryMapping ? $categoryMapping->getPrestashopCategoryId() : null;
     }
 }
コード例 #2
0
 /**
  * Get custom values (not provided by the PIM product).
  *
  * @param ProductInterface  $product
  * @param MappingCollection $attributeCodeMapping
  * @param array             $parameters
  *
  * @return array
  */
 protected function getCustomValue(ProductInterface $product, MappingCollection $attributeCodeMapping, array $parameters = [])
 {
     if ($this->belongsToVariant($product) && null !== $parameters['pimGrouped'] && !$this->hasGroupedProduct($product, $parameters['pimGrouped'])) {
         $visibility = $this->variantMemberVisibility;
     } else {
         $visibility = $this->visibility;
     }
     $customValue = [strtolower($attributeCodeMapping->getTarget(self::VISIBILITY)) => $visibility, strtolower($attributeCodeMapping->getTarget(self::ENABLED)) => (string) $this->enabled ? 1 : 2, strtolower($attributeCodeMapping->getTarget('created_at')) => $product->getCreated()->format(AbstractNormalizer::DATE_FORMAT), strtolower($attributeCodeMapping->getTarget('updated_at')) => $product->getUpdated()->format(AbstractNormalizer::DATE_FORMAT), strtolower($attributeCodeMapping->getTarget('categories')) => $this->getProductCategories($product, $parameters['categoryMapping'], $parameters['scopeCode'])];
     if (false === $parameters['urlKey']) {
         $customValue[strtolower($attributeCodeMapping->getTarget(self::URL_KEY))] = $this->generateUrlKey($product, $attributeCodeMapping, $parameters['localeCode'], $parameters['scopeCode'], $parameters['skuFirst']);
     }
     return $customValue;
 }
コード例 #3
0
 /**
  * Is the given attribute ignored ?
  *
  * @param AbstractAttribute $attribute
  * @param MappingCollection $attributeMapping
  *
  * @return boolean
  */
 protected function isAttributeIgnored(AbstractAttribute $attribute, MappingCollection $attributeMapping)
 {
     return in_array(strtolower($attributeMapping->getTarget($attribute->getCode())), $this->getIgnoredAttributes()) || $attribute->getAttributeType() === self::IMAGE_ATTRIBUTE_TYPE;
 }
コード例 #4
0
 /**
  * Get normalized labels for attribute.
  *
  * @param AbstractAttribute $attribute
  * @param array             $prestashopStoreViews
  * @param string            $defaultLocale
  * @param MappingCollection $storeViewMapping
  * @param MappingCollection $attributeMapping
  *
  * @return array
  */
 protected function getNormalizedLabels(AbstractAttribute $attribute, array $prestashopStoreViews, $defaultLocale, MappingCollection $storeViewMapping, MappingCollection $attributeMapping)
 {
     $localizedLabels = [];
     foreach ($prestashopStoreViews as $prestashopStoreView) {
         $localeCode = $storeViewMapping->getSource($prestashopStoreView['code']);
         $localizedLabels[] = ['store_id' => $prestashopStoreView['store_id'], 'label' => $this->getAttributeTranslation($attribute, $localeCode, $defaultLocale)];
     }
     return array_merge([['store_id' => 0, 'label' => strtolower($attributeMapping->getTarget($attribute->getCode()))]], $localizedLabels);
 }
コード例 #5
0
 /**
  * Get the corresponding storeview for a given locale.
  *
  * @param string            $locale
  * @param array             $prestashopStoreViews
  * @param MappingCollection $storeViewMapping
  *
  * @return string
  */
 protected function getStoreViewForLocale($locale, $prestashopStoreViews, MappingCollection $storeViewMapping)
 {
     return $this->getStoreView($storeViewMapping->getTarget($locale), $prestashopStoreViews);
 }
コード例 #6
0
 /**
  * Get the corresponding storeview code for a givent locale.
  *
  * @param string            $locale
  * @param array             $prestashopStoreViews
  * @param MappingCollection $storeViewMapping
  *
  * @return string
  */
 protected function getStoreViewForLocale($locale, $prestashopStoreViews, MappingCollection $storeViewMapping)
 {
     return ['code' => $storeViewMapping->getTarget($locale)];
 }