1

私は理解しようとして何時間も費やしましたが、失敗しました。Magento で「製造元」属性のラベルと値を抽出する必要があります。しかし、店舗固有の説明ではなく、管理者フィールドにある説明を取得する必要があります。

ストア固有のものを取得する多くの方法を見つけました。また、属性のすべてのオプションを抽出することもできましたが、製品ページから現在の記事 + 管理値 + 管理ラベルの組み合わせだけを取得することはできませんでした (どのストアからでも)。アクセスしています。)

誰かがそれを助けることができますか?

これにより、すべての値とラベルの配列が得られますが、具体的な記事ではありません。

<pre><code>
$attribute = $_product->getResource()->getAttribute('manufacturer');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
$attributeArray[$option['value']] = $option['label'];
}
</code></pre>
4

1 に答える 1

2

製品メーカーの価値を取得し、次のようなオプションの配列からラベルを取得するだけです。

$manufacturerOfProduct = $product->getManufacturer();
$attribute = $_product->getResource()->getAttribute('manufacturer');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
   $attributeArray[$option['value']] = $option['label'];
}
var_dump("Product manufacturer value is ".$manufacturerOfProduct." and label is ".$attributeArray[$manufacturerOfProduct]);
于 2013-01-11T17:02:34.343 に答える