无法获得基本的自定义Magento支付模块

时间:2011-09-14 16:32:19

标签: magento module payment

我想创建一个与Check / Money Order方法基本相同的支付模块,当您单击单选按钮选择它时,下面会显示一些带有说明的信息。

我创建了一个可行的模块,但我无法将信息显示在下方。当我启用它时,我只是得到一个空白的错误页面(没有消息)。

我的模块文件夹中有以下文件:

  • 阻止/表格/ Bacs.php
  • 阻止/信息/ Bacs.php
  • 等/ config.xml中
  • 等/的system.xml
  • 型号/方法/ Bacs.php

前端方面我有以下文件:

  • 付款/信息/ bacs.phtml
  • 付款/形式/ bacs.phtml

我认为问题在于我的块php文件,因为当我从我的模型文件中删除它们的链接时,该模块可以工作。以下是我认为存在问题的文件的概述:

模型/方法/ Bacs.php

class Creare_Bacs_Model_Method_Bacs extends Mage_Payment_Model_Method_Abstract
{

    protected $_code  = 'bacs';
    protected $_formBlockType = 'bacs/form_bacs';
    protected $_infoBlockType = 'bacs/info_bacs';

    public function assignData($data)
    {
        $details = array();

        if ($this->getInstructions()) {
            $details['instructions'] = $this->getInstructions();
        }
        if (!empty($details)) {
            $this->getInfoInstance()->setAdditionalData(serialize($details));
        }
        return $this;
    }

    public function getInstructions()
    {
        return $this->getConfigData('instructions');
    }

}

阻止/信息/ Bacs.php

class Creare_Bacs_Block_Info_Bacs extends Mage_Payment_Block_Info
{

    protected $_instructions;

    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('payment/info/bacs.phtml');
    }

    public function getInstructions()
    {
        if (is_null($this->_instructions)) {
            $this->_convertAdditionalData();
        }
        return $this->_instructions;
    }

    protected function _convertAdditionalData()
    {
        $details = @unserialize($this->getInfo()->getAdditionalData());
        if (is_array($details)) {
            $this->_instructions = isset($details['instructions']) ? (string) $details['instructions'] : '';
        } else {
            $this->_instructions = '';
        }
        return $this;
    }

}

阻止/形式/ Bacs.php

class Creare_Bacs_Block_Form_Bacs extends Mage_Payment_Block_Form
{

    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('payment/form/bacs.phtml');
    }

}

在我的system.xml文件中,我有这个,它显示了下图中的textarea指令:

<instructions translate="label">
              <label>Instructions</label>
              <frontend_type>textarea</frontend_type>
              <sort_order>2</sort_order>
              <show_in_default>1</show_in_default>
              <show_in_website>1</show_in_website>
              <show_in_store>1</show_in_store>
</instructions>

enter image description here

真的不确定我做错了什么。我不希望第一篇文章太长,所以如果需要更多文件,请告诉我。我确定问题出在我提供的块文件中。

有人能告诉我,如果我在创建上面显示的任何文件时出错吗?

1 个答案:

答案 0 :(得分:3)

我是个假人。忘了在config.xml中注册块(你会发现它是Anton S)

<blocks>
    <bacs>
       <class>Creare_Bacs_Block</class>
    </bacs>
</blocks>