我使用贝宝作为网关,我想我会编辑IPN监听器并根据贝宝结果更新客户组。Magento - 成功订单更改客户组
有没有更像'Magento'这样做的方式,就像重写方法一样,如果是的话,我会在那里做什么?
我使用贝宝作为网关,我想我会编辑IPN监听器并根据贝宝结果更新客户组。Magento - 成功订单更改客户组
有没有更像'Magento'这样做的方式,就像重写方法一样,如果是的话,我会在那里做什么?
事件观察者在这里会有意义。不知道paypal_payment_transaction_save_after
事件会在这里工作;在保存成功的IPN付款后检查订单将起作用。
为别人找这个功能,这是我做的:
要覆盖的Magento 1.7.0.2贝宝例程我复制
/应用/代码/核心/法师/贝宝/
到
/应用程序/代码/本地/法师/贝宝/
我然后加入下面的方法来/app/code/local/Mage/Paypal/Model/Ipn.php
protected function _changeUserGroup($group){
$invoice_id = $this->_request['invoice'];
// get the resource model
$resource = Mage::getSingleton('core/resource');
// retrieve the read connection
$read = $resource->getConnection('core_read');
// get the customer_id for the invoice from the database
$customer_id = (int) $read->fetchOne($read->select()->from('sales_flat_order','customer_id')->where("increment_id='$invoice_id'")->limit(1));
// retrieve the write connection
$write = $resource->getConnection('core_write');
// raw query
$query = "UPDATE customer_entity SET group_id = $group WHERE entity_id = $customer_id";
// execute the query
$write->query($query);
}
然后,您可以在IPN过程中的任何位置调用此方法以适合您的目的。我发现http://fishpig.co.uk/blog/direct-sql-queries-magento.html对数据库调用很有用。