How to get sku from sales_flat_invoice_item table? Which model is use for this table?

  • The sku for what? You have a specific invoice id or a product id? Can you explain your scenario a bit? – Marius Feb 13 '15 at 13:34
  • I have specific order item id using this i want sku understand or not? – ND17 Feb 13 '15 at 13:36

If you have the order item id, then the sku for the order item should be the same as the sku for the invoice item. so you don't need to go to the invoice items table to get it.

$itemId = 100;
$item = Mage::getModel('sales/order_item')->load($itemId);
$sku = $item->getSku();

but if you insist on getting it from the invoice item table do this:

$collection = Mage::getModel('sales/order_invoice_item')->getCollection()
    ->addFieldToFilter('order_item_id', $itemId);

$invoiceItem = $collection->getFirstItem();
if ($invoiceItem->getId()) {
    $sku = $invoiceItem->getSku();
else {
    //the invoice item does not exist
/** @var Mage_Sales_Model_Order $order */
$order = Mage::getModel('sales/order')->load(182);

foreach ($order->getInvoiceCollection() as $invoice) {
    /** @var $invoice Mage_Sales_Model_Order_Invoice */
    foreach ($invoice->getAllItems() as $invoiceItem) {
        /** @var $invoiceItem Mage_Sales_Model_Order_Invoice_Item */

An invoice Item is related to a invoice which is related to a order, you can also load a invoice directly by:


or an invoice item by


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.