【问题标题】:Magento - Admin attribute name for concrete productMagento - 具体产品的管理属性名称
【发布时间】:2013-01-11 16:42:14
【问题描述】:

我花了几个小时试图弄清楚但失败了。我需要在 Magento 中为“制造商”属性提取标签和值。但我需要获取管理字段中的描述 - 而不是特定于商店的描述。

我找到了很多方法来获取特定于商店的信息,我也可以提取属性的所有选项,但不能只从产品页面中获取当前文章 + 管理值 + 管理标签的组合(无论我从哪个商店访问它)。

有人可以帮忙吗?

这给出了所有值+标签的数组,但不适用于具体文章:

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

【问题讨论】:

    标签: php magento attributes label admin


    【解决方案1】:

    只需获取产品制造商的价值并从您的一系列选项中获取标签,如下所示:

    $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]);
    

    【讨论】:

    • 非常感谢您的帮助!现在工作得很好!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-11
    相关资源
    最近更新 更多