Magento Model 源模型 - 在出现非对象错误时调用成员函数 toOptionArray()
我正在尝试在 Magento 中的自定义模块上设置 source_model 。 模块位于本地/Bitstream/Selfawb 在 system.xml 中我有这个:
<email_type translate="label">
<label>Email Type</label>
<frontend_type>multiselect</frontend_type>
<source_model>bitstream/source_emailType</source_model>
<sort_order>3</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</email_type>
EmailType.php 位于 /local/Bitstream/Selfawb/Model/EmailType.php 中,代码如下:
class Bitstream_Selfawb_Model_Source_EmailType{
public function toOptionArray(){
return array(
array('value'=>'mobile', 'label'=>Mage::helper('mailchimp')->__('MOBILE')),
);
}
}
问题是我在浏览器中收到此错误: 致命错误:调用成员函数toOptionArray() 在非对象上
我在这里做错了什么?
I'm trying to set a source_model on a custom module in Magento.
module is in local/Bitstream/Selfawb
in system.xml I have this:
<email_type translate="label">
<label>Email Type</label>
<frontend_type>multiselect</frontend_type>
<source_model>bitstream/source_emailType</source_model>
<sort_order>3</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</email_type>
And EmailType.php is in /local/Bitstream/Selfawb/Model/EmailType.php with the folowing code:
class Bitstream_Selfawb_Model_Source_EmailType{
public function toOptionArray(){
return array(
array('value'=>'mobile', 'label'=>Mage::helper('mailchimp')->__('MOBILE')),
);
}
}
The problem is I get this error in browser: Fatal error: Call to a member function toOptionArray() on a non-object
What am I doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是路径
/local/Bitstream/Selfawb/Model/EmailType.php
中应该有一个“Source”。/local/Bitstream/Selfawb/Model/Source/EmailType.php
The answer is the path
/local/Bitstream/Selfawb/Model/EmailType.php
should have a "Source" in it./local/Bitstream/Selfawb/Model/Source/EmailType.php