The question of how to create a credit memo in Magento 1 has been asked several times and answered in a few different ways.

With each one, I'm yielded slightly different results but ultimately each has the same result:

A credit memo for $0 with no items listed in the "Items Refunded" section, or the full quantity of items ordered being refunded, and the quantities are ignored.

In this case, $rma is a single RMA object from getCollection(), and the result of the below code is that all items are refunded even though the qty_authorized is 1.

$order = $rma->getOrder();
$service = Mage::getModel('sales/service_order', $order);
$rmaItems = $rma->getItemsForDisplay();

$data = array(
    'items' => array()

foreach($rmaItems as $rmaItem){
    $data["items"][strval($rmaItem->getId())] = ['qty'=>$rmaItem->getData('qty_authorized')];

$data['shipping_amount'] = 0;

$creditMemo = $service->prepareCreditmemo($data)->register();


The above example is passing in items, and yields the following structure for the data variable:

array(2) {
  array(1) {
    array(1) {
      string(6) "1.0000"

Switching the variable from items to qtys as in most answers yields the same structure but instead gives the result where no items are returned.

This is all very much beta code, and there's bound to be errors in other parts of it as so far I'm working on just getting a proper credit memo in, so any comments on any part of it are much appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.