0
我正在尝试为自定义属性设置自定义后端模型。问题在于Magento会将'Mage'目录加到路径中,所以我无法将所有文件保留在我的扩展目录中。将自定义后端模型添加到自定义属性
代码:
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('catalog_category', $postData['attribute_code'], array(
'label' => $postData['frontend_label'],
'input' => $postData['frontend_input'],
'backend' => 'my_company/myextension_model_category_attribute_backend_file',
'required' => $postData['is_required'],
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'group' => $postData['attribute_group_name'],
'sort_order' => $postData['sort_order']
));
相反的路径是相对于我的延伸,“法师”被前缀并导致这个错误:
Warning: include(Mage/My_Company/Model/My_Extension/Model/Category/Attribute/Backend/File.php): failed to open stream
我还没有找到一个可行的解决方案使用addAttribute()方法。
在进行故障排除时,并未立即明确Magento在何处预先设置路径。
一切都很好(我正在使用文件渲染器),但它没有正确保存后端,当然。
我在Magento 1.6.1上。
关闭,看来我的语法是关闭的。更改我的配置,然后将我的后端更改为'company/category_attribute_backend_file',导致路径'Company/Extension/Model/Category/Attribute/Backend/File.php'的打开流警告失败 – 2012-02-13 02:21:17
好吧,将后端添加到“扩展名/文件”工作。我也必须更新我的班级名称/路径。谢谢先生。 – 2012-02-13 02:29:43