【问题标题】:How add attribute to Admin Product's custom tab如何将属性添加到管理产品的自定义选项卡
【发布时间】:2013-04-10 07:13:57
【问题描述】:

我在管理产品上创建了一个标签。通过以下方式。

  <adminhtml_catalog_product_edit>
    <reference name="product_tabs">
        <action method="addTab" ifconfig="customoptionspricing/general/enable" ifvalue="1">
            <name>customoptionspricing_tab</name>
            <block>customoptionspricing/adminhtml_catalog_product_tab</block>
        </action>
    </reference>
</adminhtml_catalog_product_edit> 

选项卡显示完美,我在其 phtml 文件中显示了一些自定义数据。

现在我必须在此选项卡的内容中显示产品自定义属性。我不知道如何使用这个 phtml 文件或任何其他方式添加它。

我尝试添加这样的属性:

    $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
    $setup->addAttribute('catalog_product', 'is_cop_product', array(
                 'group'    => 'Custom Options Pricing',
                 'label'    => 'Is Custom Options Pricing (COP) Product',            
                 'type' => 'int',
                 'input'    => 'boolean',                     
                 'visible'  => true,
                 'required' => true,
                 'position' => 1,
                 'global'   => 'Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL',
         'note'    => "is product a cop product"
    ));

但是这样它会创建另一个带有此属性的选项卡(新组)。

所以我需要将此属性添加到我已经创建的选项卡上。??谢谢

【问题讨论】:

  • 您是否找到了更多相关信息?我只使用addAttribute 添加自定义属性。但我使用了general 组。现在我正在研究如何更改自定义属性的组,使其显示在另一个选项卡中。

标签: magento tabs product custom-attributes


【解决方案1】:

尝试设置used_in_forms

Mage::getSingleton( 'eav/config' )
    ->getAttribute( 'catalog_product','is_cop_product')
    ->setData( 'used_in_forms', array( 'customoptionspricing_tab' ) )
    ->save();

这在 1.8 和 1.9 上对我们有用。在我们的例子中,它是一个客户属性,但我不明白为什么它不适用于产品。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-12
    相关资源
    最近更新 更多