コード例 #1
0
 /**
  * Get product price from generated mapping.
  *
  * @param ProductInterface  $product
  * @param array             $priceChanges
  * @param float             $basePrice
  * @param MappingCollection $attributeMapping
  *
  * @return float
  */
 protected function getProductPriceFromMapping(ProductInterface $product, array $priceChanges, $basePrice, MappingCollection $attributeMapping)
 {
     $priceFromMapping = $basePrice;
     foreach ($priceChanges as $attributeCode => $attributePriceMapping) {
         $priceFromMapping += $this->getAttributePriceFromMapping($product, $attributeMapping->getSource($attributeCode), $attributePriceMapping);
     }
     return $priceFromMapping;
 }
コード例 #2
0
 /**
  * Generate url key from product name and identifier.
  * The identifier is included to make sure the url_key is unique, as required in Prestashop.
  *
  * If name is localized, the default locale is used to get the value.
  *
  * @param ProductInterface  $product
  * @param MappingCollection $attributeCodeMapping
  * @param string            $localeCode
  * @param string            $scopeCode
  * @param boolean           $skuFirst
  *
  * @return string
  */
 protected function generateUrlKey(ProductInterface $product, MappingCollection $attributeCodeMapping, $localeCode, $scopeCode, $skuFirst = false)
 {
     $identifier = $product->getIdentifier();
     $nameAttribute = $attributeCodeMapping->getSource(self::NAME);
     $name = $product->getValue($nameAttribute, $localeCode, $scopeCode);
     if (false === $skuFirst) {
         $url = Urlizer::urlize($name . '-' . $identifier);
     } else {
         $url = Urlizer::urlize($identifier . '-' . $name);
     }
     return $url;
 }
コード例 #3
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);
 }