我正在开发一个自定义忠诚度积分模块。在结账期间,客户可以选择兑换积分。
在模块设置中,我创建了一个redeem_points eav_attribute(它存在于eav_attribute 表中)并且我已将属性添加到报价中,嗯,有点......
这是我的做法:
- 在 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 的方法 savePoints($data) 被调用:
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 中调试了报价对象:此时(在结帐的这一步中,只是在将其保存到报价中之后)我可以看到具有正确值的 redempted_points 属性。
我的问题是,在下一步中,这个属性从报价对象中消失了:(
所以我知道我还没有完全设法将我的redeed_points 属性包含在报价对象中,但我真的不知道我错过了什么。 ..
任何人的想法?