【问题标题】:Show attribute in a particular category products in Magento admin在 Magento admin 中显示特定类别产品的属性
【发布时间】:2016-07-07 09:23:22
【问题描述】:

我想显示特定类别产品的属性,因为它对其他类别产品没有用。每个类别产品都有特定的属性定义,每个类别产品的所有属性都不同。

所以,我不想显示所有产品的所有属性。我只想显示特定类别产品所需的那些属性。有没有办法根据类别产品定义属性?

【问题讨论】:

    标签: magento attributes magento-1.9 custom-attributes


    【解决方案1】:

    这是一个选项:

    1. 基于默认属性集创建了一个新属性集。
    2. 将所需的属性分配到新的属性集中。
    3. 在产品添加过程中选择新创建的属性集。

    您可以将这个新创建的属性集用于您的目标类别。

    【讨论】:

    • 请仔细阅读问题.......我知道如何从管理员添加属性并在前端使用它。但我只想显示少数产品的属性而不是所有产品
    【解决方案2】:

    您可以在 view.phtml 文件中编写此代码。

    <?php
        $product_id = $_product->getId();
        $your_custom_product_id = array('51','52','53','54','55','56'); // Your customs Product Ids
        
        if(in_array($product_id,$your_custom_product_id)) {
            $attribute = $_product->getResource()->getAttribute(‘attribute_code’);
            echo $attribute->getFrontendLabel();
            echo $attributeValue = Mage::getModel(‘catalog/product’)->load($_product->getId())->getMyAttribute();
        }
    ?>
    

    【讨论】:

    • 上面的代码是显示在前端,但我希望该属性显示在管理员中,根据特定产品的类别明智.....不是在每个产品中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    • 1970-01-01
    • 2017-03-27
    • 1970-01-01
    • 1970-01-01
    • 2019-04-29
    • 1970-01-01
    相关资源
    最近更新 更多