0

I added a custom attribute in the products table:

$installer->addAttribute('catalog_product', 'custom_attribute', array(
    'group'             => 'General',
    'type'              => Varien_Db_Ddl_Table::TYPE_VARCHAR,
    'backend'           => '',
    'frontend'          => '',
    'label'             => 'Custom Attribute',
    'input'             => 'text',
    'class'             => '',
    'source'            => '',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'visible'           => true,
    'required'          => false,
    'user_defined'      => true,
    'default'           => '',
    'searchable'        => true,
    'filterable'        => true,
    'comparable'        => true,
    'visible_on_front'  => true,
    'unique'            => false,
    'apply_to'          => 'simple,configurable,virtual',
    'is_configurable'   => false
));

It shows up correctly in the general tab of the product edit screen.
I should have created a new custom tab for this attribute. How can I change it so it shows up in a new custom tab?

Saw this similar question here move to another group
But the group does not exist yet.

4

2 回答 2

0

想出了这个解决方案,将属性移动到另一个选项卡/组。

$setId = $installer->getDefaultAttributeSetId('catalog_product');

$groupId = $installer->getAttributeGroupId($installer->getEntityTypeId('catalog_product'), $setId, 'Custom group');

$installer->addAttributeToGroup('catalog_product', $setId, $groupId, 'shop_id', 1000);
$installer->addAttributeToGroup('catalog_product', $setId, $groupId, 'size_chart', 9010);

这会将属性移动到另一个组。请注意,在更改组 ID 之前,我首先必须添加一个具有正确组名的新属性(无论如何我都需要)。

于 2013-08-28T09:59:03.613 回答
0

group元素设置新选项卡的名称。如果选项卡不存在,Magento 会自动创建它。

$installer->addAttribute('catalog_product', 'custom_attribute', array(
    'group'             => 'New tab label here',
    ...
));
于 2013-08-26T10:31:17.380 回答