Browsing articles tagged with "invoice Archives - Kalpesh Mehta"
Apr 28, 2013
kalpesh

Magento get all invoices and shipments of an order

Getting all the invoices of an order:

1
2
3
4
5
6
7
8
$order = Mage::getModel('sales/order')->load($orderID);
if ($order->hasInvoices()) {
    $invIncrementIDs = array();
    foreach ($order->getInvoiceCollection() as $inv) {
        $invIncrementIDs[] = $inv->getIncrementId();
    //other invoice details...
    } Mage::log($invIncrementIDs);
}

Getting all the shipments of an order:

1
2
3
4
5
$order = Mage::getModel('sales/order')->load($orderID);
foreach($order->getShipmentsCollection() as $shipment)
{
    Mage::log($shipment->getData()); //get each shipment data here...
}
Jan 24, 2013
kalpesh

Magento: Add additional product/item attributes in order and invoice emails

Recently I was working with a German client, who wanted to show additional product attribute options in the order and invoice emails due to stricter law for e-commerce in their country. Magento provides basic information in the default email templates, but each store has their unique requirement to show additional information.

I will show you how to add extra product attribute values, along with order item options and custom options in order emails and invoice emails.

Here is the code that should work for order and invoice emails to get additional PRODUCT ATTRIBUTES displayed:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$productId = $_item->getProduct()->getId(); //for order emails
//$productId = $_item->getProductId(); //for invoice emails
$product = Mage::getModel('catalog/product')->load($productId);
$attributes = $product->getAttributes();

//Get a list of all PRODUCT ATTRIBUTES you want to show in this array...
$dispAttribs = array('hardrive', 'memory', 'processor'); 

foreach ($attributes as $attribute) {    
        $attributeCode = $attribute->getAttributeCode();
        if(!in_array($attributeCode, $dispAttribs)) continue;
        $label = $attribute->getFrontend()->getLabel($product);
        $value = $attribute->getFrontend()->getValue($product); 
        echo "<br /><strong>" . $label . ":</strong> " . $value;
}

Continue reading »

Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!

Certifications