I am trying to edit a credit memo email template. Currently when a credit memo is submitted the template renders all of the products from the order.

  <?php $i=0; foreach ($_order->getAllItems() as $_item): ?>
       <?php if($_item->getParentItem()) continue; else $i++; ?>
       <tbody<?php echo $i%2 ? '' : '' ?>>
       <?php echo $this->getItemHtml($_item) ?>
  <?php endforeach; ?>

I need to get the returns data so I can tell the loop to ignore products with the id of any returned items from an order. As far as I can see return details are not included in the order object. So how, using the order id, can I get a list of returned products from an order.

Any alternative methods/suggestions welcome also.


I was able to get the related credit memo details using the order id. Here's the code I used.

  $_order = $this->getOrder();
  $orderid = $_order->getId();
  $creditMemos = Mage::getResourceModel('sales/order_creditmemo_collection');
  $creditMemos->addFieldToFilter('order_id', $orderId);

Your need to get the products from an order right? Your logic is allright, remember that as the quote have items on it, respectively tables sales_flat_quote and sales_flat_quote_item, a quote that became an order will have its registers respectively in sales_flat_order and sales_flat_order_item

To get a the product instance from an item you can do $item->getProduct()...

I think i dont undestand when you say "return datails", but maybe this infos can help...

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.