我正在尝试使用自定义源向现有组添加新属性。但是,该属性永远不会出现在UI中。
是的,我已禁用缓存并在我的模块的config.xml中出现问题。这是mysql4-upgrade脚本
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$entityTypeId = Mage::getModel('eav/entity')
->setType('catalog_product')
->getTypeId();
$installer->addAttribute($entityTypeId, 'editor_form', array(
'group' => 'mygroup',
'input' => 'select',
'type' => 'int',
'label' => 'Editor form',
'backend' => '',
'visible' => 1,
'required' => 0,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'unique' => false,
'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
'is_configurable' => false,
'source' => 'sourcetype/attribute_source_type',
'frontend_class' => '',
'frontend' => '',
'used_in_product_listing' => false,
'sort_order' => 5,
));
$installer->endSetup();
app / code / local / mycompany / w2p / Attribute / Source
中的自定义源代码<?php
class mycompany_w2p_Sourcetype_Model_Attribute_Source_Type extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{
public function toOptionArray()
{
return array(
array('value' => 0, 'label'=>'Standard form'),
array('value' => 1, 'label'=>'Custom form'),
);
}
}