当refund发生在线下,需要用程序加creditmemo时,如下代码可供参考
1.可以调用sales/order_creditmemo_api的create()方法来生成creditmemo记录,
function addCreditMemo($targetMagentoGoServiceId, $orderId, $commentText) {
$product = Mage::getModel('catalog/product')->load($targetMagentoGoServiceId);
$targetMagentoGoPrice = $product->getPrice();
$targetCustomerServicePrice = $this->getCustomerServicePrice($orderId);
$targetTotalAmount = $targetMagentoGoPrice + $targetCustomerServicePrice;
$remainAmount = $this->getRemainTotalAmount($orderId);
$refundAmount = $targetTotalAmount - $remainAmount;
$data = array(
'qtys'=>array(),
'adjustment_negative' => 0,
'adjustment_positive' => $refundAmount,
'shipping_amount' => '0'
);
Mage::getModel('sales/orde