wes
wes

Reputation: 53

How can I get a list of products related to an invoice in magento?

I am trying to alphabetize the items listed on an invoice in the backend of a magento site.

I have access to the Mage_Adminhtml_Block_Sales_Order_Invoice_View_Items object used to display these items in the backend.

Is there any way I can use this object to get a list of product skus and reorder these items?

Edit:

Here's the line of code that's gathering the objects for display in the view. I imagine I'd need to get the items sorted before this point –

<?php $_items = $this->getInvoice()->getAllItems() ?>

Upvotes: 1

Views: 4729

Answers (2)

Andrey Korolyov
Andrey Korolyov

Reputation: 996

You should attach you handler on event "sales_order_invoice_item_collection_load_before". Get collection object from event and attach this function

$invoiceObject->addAttributeToSort('sku', 'desc')

Upvotes: 1

Anton S
Anton S

Reputation: 12750

you can try this:

$this->getInvoice()->getItemsCollection()->addAttributeToSort('sku', 'desc')

Upvotes: 0

Related Questions