Magento Model 源模型 - 在出现非对象错误时调用成员函数 toOptionArray()

发布于 2024-12-21 08:57:15 字数 1124 浏览 1 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰◇生如夏花灿烂 2024-12-28 08:57:15

答案是路径 /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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文