在CompanyName \ MyModuleName \ sql \ companyname_modulename_setup的sql文件中,为了创建该列,请复制以下代码。
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addColumn($installer->getTable('sales/quote'),
'paypal_status',
array(
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
'nullable' => true,
'comment' => 'Paypal Status',
)
);
$installer->endSetup();
注销并登录,并刷新magento缓存以将列添加到表中。
Express Checkout控制器在app/code/core/Mage/Paypal/Controller/Express/Abstract.php中。如果您想在控制器重定向到paypal之前添加一个字段,您可以修改_initCheckout()方法,如下所示:
protected function _initCheckout()
$quote = $this->_getQuote();
if (!$quote->hasItems() || $quote->getHasError()) {
$this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
Mage::throwException(Mage::helper('paypal')->__('Unable to initialize Express Checkout.'));
}
$quote->setPaymentStatus(1); // Here is your change
$this->_checkout = Mage::getSingleton($this->_checkoutType, array(
'config' => $this->_config,
'quote' => $quote,
));
return $this->_checkout;
}
好的,这非常简单。我知道setPaypalStatus()方法是那些“神奇的”PHP __call方法之一(http://php.net/manual/en/language.oop5.overloading.php)。为了读者的利益 –
我也想添加一个列,如果它不存在,这个链接是有帮助的: http://www.magento60s.com/magento/add-column-if- not-exist-2615.html –
如果不存在,可以检查这些链接以添加列:http:// stackoverflow。com/questions/24571611/mysql-alter-table-if-column-not-exist –