【发布时间】:2012-02-13 10:09:56
【问题描述】:
我正在尝试为自定义属性设置自定义后端模型。问题是 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']
));
'Mage' 不是相对于我的扩展名的路径,而是前置并导致此错误:
Warning: include(Mage/My_Company/Model/My_Extension/Model/Category/Attribute/Backend/File.php): failed to open stream
我还没有找到适用于 addAttribute() 方法的解决方案。
在疑难解答中,Magento 在哪里添加路径并不清楚。
一切都渲染得很好(我使用的是文件渲染器),但是如果没有后端,它当然不能正确保存。
我正在使用 Magento 1.6.1。
【问题讨论】:
标签: magento