[size=4]I have a cron job running a customized add on. The cron job is setup to send emails but when i try to start assigning variables to $view_mail it produces an error:[/size]
Call to a member function assign() on a non-object.
The line where this error occurs inside erporders_export.php has the following code:
[size=4]$view_mail->assign('order_info', $order_info);
[/size]
[size=4]Here is the code used to load my add on: [/size]
[size=4]
define('AREA', 'A'); define('AREA_NAME', 'admin'); $mode = $_REQUEST['--mode'];
[/size]
require_once("./prepare.php"); require_once("./init.php");
require_once(DIR_ADDONS."erporders/controllers/admin/erporders_export.php"); ?>
As far as I can tell init.php should be initializing the $view_mail and everything should be working. I can't figure out why its not. If anyone has any clue what i'm missing please let me know.
Got it. In case anyone needs to know I couldn't just use
$view_mail->assign('order_info', $order_info);
I had to access it using the Registry get like this:
Registry::get('view_mail')->assign('order_info', $order_info);
It probably would have worked if you'd have done it after the template engine was initialized. I.e. following your includes for prepare.php and init.php.
I though that was what i did. My include is after prepare and init
as per my posted source code. Is that what you mean?
In your original post in the area of:
[quote]
[size=4]Here is the code used to load my add on: [/size]
[size=4][/quote][/size]
[size=4]You have your $view->assign() right after your [/size]
My apologies that was a copy/paste error. the view code is actually inside the erp_export_orders.php file which is after the prepare and init. I have updated my OP to reflect this more clearly. sorry.
Thank you! One of the few people who actually reply to their initial post with the answer.
Helped me greatly!