获取产品属性参考-Prestashop 1.7

时间:2019-04-06 11:59:03

标签: php variables attributes prestashop

我需要在模块php文件中获得ean13的产品组合。 使用这个我可以获得产品参考:

               $product = new 
               Product(Tools::getValue('id_product'));
               $varRef = $product->reference;

我不知道如何获得ean13组合,因为它是一系列产品。

{$product|@var_dump}}
'attributes' => 
  array (size=2)
   1 => 
    array (size=8)
      'id_attribute' => string '1' (length=1)
      'id_attribute_group' => string '1' (length=1)
      'name' => string 'S' (length=1)
      'group' => string 'Taille' (length=6)
      'reference' => string '' (length=0)
      'ean13' => string '' (length=0)
      'isbn' => string '' (length=0)
      'upc' => string '' (length=0)

任何快速解决方案? 谢谢!

1 个答案:

答案 0 :(得分:1)

这有效,并将列出给定产品的每个组合/变体的EAN 13:

$product = new Product((int)Tools::getValue('id_product'));
$id_lang = Context::getContext()->language->id;
$combinations = $product->getAttributeCombinations((int)$id_lang, true);
foreach ($combinations as $c)
    p($c['ean13']);