致命错误:在非对象上调用成员函数toOptionArray() [英] Fatal error: Call to a member function toOptionArray() on a non-object

查看:106
本文介绍了致命错误:在非对象上调用成员函数toOptionArray()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Magento中开发一种付款方式模块.当我在Magento的配置中单击付款方式菜单时,出现以下错误

I am developing a payment method module in Magento. When I click payment methods menu in Configuration of Magento I get the below error

Fatal error: Call to a member function toOptionArray() on a non-object in
\xampp\htdocs\magento\app\code\core\Mage\Adminhtml\Block\System\Config\Form.php
on line 421

请参见下面的链接,了解我正在开发的模块的代码

Please see the below link for the code of module which I was developing

Magento模块致命错误:在第516行的\ xampp \ htdocs \ magento \ app \ Mage.php中找不到类'Mage_Cashondelivery_Helper_Data'

我正在使用Xampp 1.7.3和magento 1.6.1. 请帮忙.

I am using Xampp 1.7.3 and magento 1.6.1. Please help.

推荐答案

在您的system.xml中,您具有以下代码

In your system.xml you have the following code

<payment_action translate="label">
    <label>Payment Action</label>
    <frontend_type>select</frontend_type>
    <source_model>cashondelivery/createorder</source_model>
    <sort_order>2</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>0</show_in_store>
</payment_action>

源模型指定为cashondelivery/createorder.
根据您在参考问题中发布的代码,此类是一种付款方式模型,而不是源模型.
如果在模型上实现toOptionArray()方法,它也可以用作系统配置源模型,但这似乎不是一个坏选择.
我猜您正在寻找的源模型是类似paygate/authorizenet_source_paymentAction的东西.

The source model is specified as cashondelivery/createorder.
According to the code you posted in the question you reference, this class is a payment method model, not a source model.
If you implement the toOptionArray() method on the model it would work as a system config source model as well, but that doesn't seem like a bad choice.
I would guess the source model you are looking for is something like paygate/authorizenet_source_paymentAction.

Magento中存在源模型,以提供用于选择和多选的选项列表.为此,他们实现了toOptionArray()方法.
这些选项以具有以下格式的数组形式返回:

Source models in Magento exist to provide option lists to select and multiselects. For this purpose they implement the toOptionArray() method.
The options are returned as an array that has the following format:

public function toOptionArray()
{
    return array(
        array('value' => $value1, 'label' => 'The label for option 1'),
        array('value' => $value2, 'label' => 'The label for option 2'),
        array('value' => $value3, 'label' => 'The label for option 3')
        // ... etc ...
    );
}

系统配置源模型不需要扩展超类,也不需要实现除toOptionArray()之外的任何方法.
EAV select和multiselect属性也使用源模型,但是需要扩展eav/entity_attribute_source_abstract并且更复杂,因此在此不再赘述.

System configuration source models don't need to extend super class and don't need to implement any methods besides toOptionArray().
EAV select and multiselect attributes also make use of source models, but those need to extend eav/entity_attribute_source_abstract and are more complex, so I'll won't go into more details at this place.

这篇关于致命错误:在非对象上调用成员函数toOptionArray()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆