我正在一個自定義的忠誠點模塊上。客戶在結賬時可以選擇兌換積分。
在我創建了一個redeem_points eav_attribute模塊設置(它在eav_attribute表存在)和我已經加入了屬性的報價,嗯,有點...
下面是我已經做到了:新屬性添加到Magento的報價/訂單
- 在mysql4-install-0.1.0.php中我打電話$ installer-> installEntities();
- 在Namespace_Module_Model_Resource_Eav_Mysql4_Setup(其延伸Mage_Eav_Model_Entity_Setup)
僅存在1種方法公共函數getDefaultEntities()僅返回一個包含一個數組(除其他事項外):在再次
'quote' => array( 'entity_model' => 'sales/quote', 'table' => 'sales/quote', 'attributes' => array( 'redeemed_points' => array('type' => 'static') ), ),
mysql4-install-0.1.0.php我在sales_flat_quote表中創建了這個列,像這樣
//add redeemed_points to quote table $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'redeemed_points', 'bigint(20)'); $installer->addAttribute('quote', 'redeemed_points', array('type'=>'static'));
在結賬時,當我從贖回我的課延伸Mage_Checkout_Model_Type_Onepage被稱爲點,該方法保存點($數據):
public function savePoints($data)
{
//save data
if ($data == 1) {
$redeemedPoints = Mage::helper('points')->getRedeemablePoints();
$this->getQuote()->setRedeemedPoints($redeemedPoints['points']);
} else {
$this->getQuote()->setRedeemedPoints(0);
}
$this->getQuote()->collectTotals()->save();
$this->getCheckout()
->setStepData('points', 'complete', true);
if ($this->getQuote()->isVirtual()) {
$this->getCheckout()->setStepData('payment', 'allow', true);
} else {
$this->getCheckout()->setStepData('shipping_method', 'allow', true);
}
Mage::helper('firephp')->debug($this->getQuote()->debug());
return array();
}
你會發現,我調試引用對象firephp:在這一刻(在結賬的這一步,只是afetr將其保存到報價),我可以看到redeemed_points屬性,用正確的值。
我的問題是,在下一步該屬性是從報價對象:(
所以我明白我還沒有完全設法將我的redeemed_points屬性包括在報價對象,但我真的不知道我是什麼「M失蹤...
任何thaughts人嗎?
請參閱本http://stackoverflow.com/questions/4315660/alter-table-in-magento-setup -script - 不,使用SQL/4318501#4318501 – 2010-11-30 21:42:21
嗯,這個鏈接介紹瞭如何創建/修改安裝腳本里面的表,但是這不是我的問題就在這裏:在表中創建/修改,我可以看到表/字段在我的分貝。 我的問題是我不能管理包括redeemed_points到報價的對象。那麼,當我在我的Model_Type_Onepage中調用savePoints函數時,它就在那裏,但在下一步中不會消失。 – OSdave 2010-12-01 09:48:02