Magento 1.7.2 - 在Admin,Sales,Order中添加自定义字段

时间:2013-02-07 17:35:00

标签: magento magento-1.7 sales

我知道这篇文章与Stackoverflow中发布的其他帖子类似,但实际上,我尝试了给出的解决方案并且对我不起作用。

我正在关注本教程:http://www.excellencemagentoblog.com/magento-create-custom-payment-method。在第2步结束时,我应该在Admin => Sales =>订单上看到我的字段,但我看不到任何内容。

在sales_flat_quote_payment中,我可以看到“telefono_no”字段,也可以看到sales_flat_order_payment。当我买东西时,Magento将手机数据(telefono_no)保存在数据库中。无论如何,我的mysql4-install-0.1.0.php是:

$install = $this;
$install->startSetup();

$install->run("
    ALTER TABLE `".$install->getTable('sales/quote_payment')."` ADD `telefono_no` VARCHAR(7) NOT NULL DEFAULT '0000000';
    ALTER TABLE `".$install->getTable('sales/order_payment')."` ADD `telefono_no` VARCHAR(7) NOT NULL DEFAULT '0000000';
");

$install->endSetup();

在我的config.xml中,我有:

<?xml version="1.0"?>
<config>
    <modules>
        <Xs_Pago>
            <version>0.1.0</version>
        </Xs_Pago>
    </modules>
    <global>
        <fieldsets>
            <sales_convert_quote_payment>
                <telefono_no>
                    <to_order_payment>*</to_order_payment>
                </telefono_no>
            </sales_convert_quote_payment>
        </fieldsets>
    </global>
</config>

我真的不知道出了什么问题。

1 个答案:

答案 0 :(得分:0)

代码应该只将字段添加到数据库中,并在下订单时将值从quote_payment复制到order_payment。

代码不会显示任何信息,因为Mage_Payment_Block_Info

,您引用的示例中显示信息的原因
<?php
class Excellence_Pay_Block_Info_Pay extends Mage_Payment_Block_Info
{
    protected function _prepareSpecificInformation($transport = null)
    {
        if (null !== $this->_paymentSpecificInformation) {
            return $this->_paymentSpecificInformation;
        }
        $info = $this->getInfo();
        $transport = new Varien_Object();
        $transport = parent::_prepareSpecificInformation($transport);
        $transport->addData(array(
            Mage::helper('payment')->__('Check No#') => $info->getCheckNo(),
            Mage::helper('payment')->__('Check Date') => $info->getCheckDate()
        ));
        return $transport;
    }
}

看看@ Magento custom "order" attribute / admin input and display