0

I am trying to load sales orders via cron to then export via api I have successfully been able to load an order but I need to parse the same order_id into other methods and classes in order to get the data for payment, products etc...

I have tried to load the same order Id within another class but it doesn't work and I'd rather not have on big cron file with all of my functions inside...

Here is how I am loading an order in my Cron.php file:

$order = Mage::getModel('sales/order')->load($order_id->getOrderId());

This give me an instance of an order then in ProductData.php I would like to pass in the same order_id to get data from the order but this is where I am doing something wrong

ProductData.php

public function init($order_id){
    $this->order = Mage::getModel('sales/order')->load($order_id);
    return $this;
}

I was thinking about saving the order_id in Mage::registry but I'm NOT confident that it will always be available when the cron runs...

Can anyone help?

1

I'm not to sure what you are trying to do where, from the order object you can already get products and payment data but using the Mage::registry will work throughout the script you're using for the cronjob.

So as soon as you've registered the value it will remain available for the execution of the cronjobs in Magento

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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