0
// In a controller or cron script
$order_model = Mage::getModel('mypackage_module/order')->load($id);
$order_model->processStuff();

// in the model class
class Mypackage_Module_Model_Order extends Mage_Sales_Model_Order
function processStuff() {
  var_dump($this->getEntityId()); // "null"
}

the instance of Mypackage_Module_Model_Order was loaded using the load() call above, so why is getEntityId() null? What is the best practice/"Magento" way of making the model do some model processing?

1
  • I'm pretty sure you need getModel() rather than loadModel() Commented May 20, 2015 at 22:17

1 Answer 1

1

Just gave it a test and it should work, however i can tell you that it will return null if the order "entity_id" does not exist

$id = 1;
$order = Mage::getModel('mypackage_module/order')->load($id);
$order->processStuff();

class Mypackage_Module_Model_Order extends Mage_Sales_Model_Order
{
    public function processStuff()
    {
        var_dump($this->getEntityId()); // "null"
    }
}

So if order id 1 exists it should dump string(1) "1" else it will be NULL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.