Created
April 19, 2012 15:55
-
-
Save mshmsh5000/2421936 to your computer and use it in GitHub Desktop.
Magento: Load product from order item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ('Mage_Sales_Model_Order_Item' == get_class($item)) { | |
$product = null; | |
$options = $item->getProductOptions(); | |
if (!empty($options['info_buyRequest']) && !empty($options['info_buyRequest']['product'])) { | |
$product = Mage::getModel('catalog/product')->load($options['info_buyRequest']['product']); | |
if (!empty($product)) { | |
Mage::log("Loaded order product: " . $product->getName()); | |
} | |
} | |
if (empty($product)) { | |
Mage::logException(new Exception('Unable to load order product')); | |
} | |
// Mage::log($options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment