DanielaWaranie
DanielaWaranie

Reputation: 1415

Magento: How to get the creditmemo by order item quote id

i have a increment id of a magento order and a quote id of a order item (i do not mean the order item id) and i want to the all creditmemos that contains a corresponding creditmemo item for that order item.

If i use the creditmemo model in magento i can use getOrderItem() to get the order item and on that i can use getOrder() to get the order. But the order model in magento do not have a getCreditmemoItems().

Is there a better way instead of iterating over getCreditmemosCollection() of the order and over each creditmemo item?

Upvotes: 2

Views: 2459

Answers (1)

Iru
Iru

Reputation: 36

Use this:

$collection = Mage::getResourceModel('sales/order_creditmemo_collection')
        ->addAttributeToFilter('order_id', array('eq' => $order->getEntityId()))
        ->addAttributeToSelect('*');

Upvotes: 2

Related Questions