Magento 更改安装脚本中的类别属性

Magento 更改安装脚本中的类别属性,magento,installation,Magento,Installation,我有我的模块。此模块具有安装脚本,其中应将自定义图像字段添加到类别中 $setup->addAttribute('catalog_category', 'additional_image', array( 'type' => 'varchar', 'backend' => 'catalog/category_attribute_backend_image', 'label' =>

我有我的模块。此模块具有安装脚本,其中应将自定义图像字段添加到类别中

$setup->addAttribute('catalog_category', 'additional_image', array(
    'type'              => 'varchar',
    'backend'           => 'catalog/category_attribute_backend_image',
    'label'             => 'Additional Image',
    'input'             => 'image',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'visible'           => 1,
    'required'          => 0,
    'user_defined'      => 0,
    'default'           => '',
    'position'          => 6,
));

之后,它必须更改其他图像字段(图像、缩略图)的标题。如何获取此系统的字段并更改它们?

您可以使用
Mage\u Eav\u Model\u Entity\u Setup::updateAttribute()
方法来完成此操作。

这还有很长的路要走,但其他人可能需要此信息

Mage_Eav_Model_Entity_Setup::updateAttribute() 
有5个参数,其中3个是必需的

我将使用自定义客户属性的示例:

$entityTypeId = 'customer'
$id = 'my_custom_attribute_code'
$field = 'is_used_for_customer_segment'
$value = '1'
$sortOrder = Not Needed
如您所见,我正在使用customer实体更新属性。我正在用属性id(代码)my_custom_attribute_代码更新我的自定义属性。我正在对该属性中的字段进行自定义,该字段是客户段的“已使用”字段,并将该值设置为“是”(1)

下面是一个如何作为更新执行此操作的示例


您可以帮助我使用第二个和第三个参数吗?工作非常完美,但是请注意,如果您要更新默认属性,您必须使用eav_属性表中使用的确切列名,而不是别名属性代码。使用“label”作为属性代码将不起作用,您必须使用“frontend_label”!
$installer->startSetup();

$installer->updateAttribute('customer', 'my_custom_attribute_code', 'is_used_for_customer_segment', '1');

$installer->endSetup();