Improve Magento entity setup

Magento 文档鼓励用 entity setup (Mage_Eav_Model_Entity_Setup) 的方式去定义实体。这个类很强大,但我觉得不够灵活,因为无法用它精确控制 attribute, attribute group 和 attribute set。 Attribute group 和 attribute set 是在两个维度分组 attribute,这样来组织 attribute 基本够用。但 setup 这个类添加 attribute 时,有不够周到的逻辑: 如果 $attr[‘user_defined’] == 1 && empty($attr[‘group’]),那么这个 attribute 不会被添加到任何 attribute group 和 attribute set。我觉得更好的逻辑是添加到 general attribute group。 如果 empty($attr[‘user_defined’]) && !empty($attr[‘group’]),那么 $attr[‘group’] 会被忽略,attribute 总是被添加到 general attribute group。 没办法,已经这样啦,提供 install entities array… Continue reading Improve Magento entity setup