getAllItems() as $item) { if ($item->getOrderItem()->isDummy()) { continue; } $item->calcRowTotal(); $subtotal += $item->getRowTotal(); $baseSubtotal += $item->getBaseRowTotal(); $subtotalInclTax+= $item->getRowTotalInclTax(); $baseSubtotalInclTax += $item->getBaseRowTotalInclTax(); } $creditmemo->setSubtotal($subtotal); $creditmemo->setBaseSubtotal($baseSubtotal); $creditmemo->setSubtotalInclTax($subtotalInclTax ); $creditmemo->setBaseSubtotalInclTax($baseSubtotalInclTax); $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $subtotal); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseSubtotal); return $this; } }