I've created a button in the back end of my Magento 1.9 website called "Send to Printers" that I need to send JSON data to my printers API. I'm able to get some of the order information using the following:
$orderID = $this->getRequest()->getParam('order_id');
$order = Mage::getModel("sales/order")->load($orderID);
$customer = $order->getShippingAddress()->getData();
Unfortunately though the following code isn't allowing me to get information about the items of that order:
$orderItems = $order->getAllItems();
foreach ($orderItems as $itemId => $item) {
if ($item->getParentItem()) {
// This is a simple product assigned to a configurable
// You can get every single details by loading it
$product = Mage::getModel('catalog/product');
$product->load($item->getSku(),'sku');
// This variable will store all the data
$data = $product->getData();
} else if ($item->getHasChildren()) {
// This is a configurable product
}
}
The foreach never reaches any of the if
statements. What am I doing wrong?