如何向Admin Product的自定义选项卡添加属性

时间:2013-04-10 07:13:57

标签: magento tabs product custom-attributes

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

  <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"
    ));

但这样就会创建另一个带有此属性的标签(新组)。

所以我需要在已创建的选项卡上添加此属性。感谢

1 个答案:

答案 0 :(得分:0)

尝试设置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有用。在我们的例子中,它是一个客户属性,但我不明白为什么它不适用于产品。

相关问题