I've created a button in my Magento 1.9 admin that when pressed, will submit the order to our printing company (once complete). Here's how it looks at the moment:
<?php
include_once Mage::getModuleDir('controllers', 'Mage_Adminhtml') . DS . 'Sales' . DS . 'OrderController.php';
class MG_Dropship_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController {
public function dropshipAction() {
$orderID = $this->getRequest()->getParam('order_id');
$order = Mage::getModel("sales/order")->load($orderID);
$customer = $order->getShippingAddress()->getData();
$items = array();
$orderItems = $order->getAllVisibleItems();
foreach ($orderItems as $item) {
var_dump($item->sku);
At this point, it does provide me with the correct SKU. The SKU returned is for a simple product (that is linked to a configurable product). Now I'm trying to load the product model of this SKU:
$product = Mage::getModel('catalog/product');
$product->load($product->getIdBySku($item->sku));
var_dump($product);
This returns the following:
object(Mage_Catalog_Model_Product)#358 (32) {
["_cacheTag":protected]=>
string(15) "catalog_product"
["_eventPrefix":protected]=>
string(15) "catalog_product"
["_eventObject":protected]=>
string(7) "product"
["_canAffectOptions":protected]=>
bool(false)
["_typeInstance":protected]=>
I won't bother listing it all, but everything I'm trying to gain access to seems to be protected. Do I need to somehow allow access to the product model in my module?
UPDATE: I'm now able to access data such as $product->getName()
- but other data I need access to includes $product->getColor
, $product->getSize()
(these are custom attributes, but just return NULL).
debug()
method inherited fromVarien_Object
that will dump all the dynamic object properties. Example:var_dump($product->debug())