I'm loading an order like this:
$order = Mage::getModel('sales/order')->load(2886);
$items = $order->getAllItems();
Then I use a foreach loop:
foreach ($items as $itemId => $item){
$name[] = $item->getName();
$unitPrice[]=$item->getPrice();
$sku[]=$item->getSku();
$ids[]=$item->getProductId();
$qty[]=$item->getQtyToInvoice();
}
And I am able to get most of the data I need. However, I'm having problems getting the custom options that were selected for the order. I can see the data in a var dump, but I have had no success in mining it out. I've also tried a handful of built in functions that I found via google, but no luck.
matt (OP) already self-answered the question.
Quote:
I was able to get what I needed by using:
$opts = $item->getProductOptions();
Within my foreach loop. A var_dump on that shows how to access the data easily.
As Nuno Furtado stated above, this returns nothing in Magento 1.8+.
My solution was:
$opts=$item->getData('product_options');
$opts=unserialize($opts);
print_r($opts);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With