2013-01-11 54 views
1

我花了数小时试图弄清楚,但失败了。我需要为Magento中的'制造商'属性提取标签和值。但我需要获取管理字段中的说明 - 不是专门针对商店的说明。Magento - 具体产品的管理员属性名称

我发现许多方法如何获得特定商店,也可以提取该属性的所有选项,但无法获得当前文章从产品页+管理员值+管理员标签(否从哪个商店访问它)。

任何人都可以提供帮助吗?

这给所有值+标签的数组,而不是一个具体的文章:

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

回答

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]); 
+0

非常感谢您的帮助!现在工作很好! – Swip

+0

谢谢!完美的作品! – grindking