Php Magento-具体产品的管理员属性名称
我花了几个小时试图弄明白,但失败了。我需要提取Magento中“制造商”属性的标签和值。但我需要得到的描述,这是在管理领域-不是一个具体的商店 我已经找到了很多方法来获取特定于商店的内容,我还可以提取属性的所有选项,但无法从product page+admin value+admin label(无论从哪个商店访问)中获取当前文章的组合 有人能帮忙吗 这将提供一个包含所有值和标签的数组,但不适用于具体的项目:Php Magento-具体产品的管理员属性名称,php,magento,attributes,label,admin,Php,Magento,Attributes,Label,Admin,我花了几个小时试图弄明白,但失败了。我需要提取Magento中“制造商”属性的标签和值。但我需要得到的描述,这是在管理领域-不是一个具体的商店 我已经找到了很多方法来获取特定于商店的内容,我还可以提取属性的所有选项,但无法从product page+admin value+admin label(无论从哪个商店访问)中获取当前文章的组合 有人能帮忙吗 这将提供一个包含所有值和标签的数组,但不适用于具体的项目: <pre><code> $attribute = $_prod
<pre><code>
$attribute = $_product->getResource()->getAttribute('manufacturer');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
$attributeArray[$option['value']] = $option['label'];
}
</code></pre>
只需获取产品制造商的值,并从选项列表中获取标签,如下所示:
非常感谢你的帮助!现在工作得很好!非常感谢。工作完美!
$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]);