本文整理汇总了PHP中Mage_Sales_Model_Resource_Order_Abstract::_beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Resource_Order_Abstract::_beforeSave方法的具体用法?PHP Mage_Sales_Model_Resource_Order_Abstract::_beforeSave怎么用?PHP Mage_Sales_Model_Resource_Order_Abstract::_beforeSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Resource_Order_Abstract
的用法示例。
在下文中一共展示了Mage_Sales_Model_Resource_Order_Abstract::_beforeSave方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* Lookup for parent_id in already saved transactions of this payment by the order_id
* Also serialize additional information, if any
*
* @throws Mage_Core_Exception
*
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
* @return Mage_Sales_Model_Resource_Order_Payment_Transaction
*/
protected function _beforeSave(Mage_Core_Model_Abstract $transaction)
{
$parentTxnId = $transaction->getData('parent_txn_id');
$txnId = $transaction->getData('txn_id');
$orderId = $transaction->getData('order_id');
$paymentId = $transaction->getData('payment_id');
$idFieldName = $this->getIdFieldName();
if ($parentTxnId) {
if (!$txnId || !$orderId || !$paymentId) {
Mage::throwException(Mage::helper('sales')->__('Not enough valid data to save the parent transaction ID.'));
}
$parentId = (int) $this->_lookupByTxnId($orderId, $paymentId, $parentTxnId, $idFieldName);
if ($parentId) {
$transaction->setData('parent_id', $parentId);
}
}
// make sure unique key won't cause trouble
if ($transaction->isFailsafe()) {
$autoincrementId = (int) $this->_lookupByTxnId($orderId, $paymentId, $txnId, $idFieldName);
if ($autoincrementId) {
$transaction->setData($idFieldName, $autoincrementId)->isObjectNew(false);
}
}
return parent::_beforeSave($transaction);
}