I modified the default prestashop 1.5 newsletter module and made the following override of to the IdentityController
$this->context->smarty->assign('newsletter', (int)Module::getInstanceByName('modifiednewsletter')->active);
So the checkbox would appear to set/unset newsletter subscription via the "my personal information" account link.
Everything works fine but with ini_set("display_errors", 1);
i still get the following php error on the personal info page
Notice: Trying to get property of non-object in /var/www/prestashop/controllers/front/IdentityController.php on line 135 Call Stack: 0.0001 646712 1.
line 135 of IdentityController.php is
$this->context->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
When i comment out the line, the error goes away, but I really don't want to mess with the core files, can anyone tell me how to "unset" this variable through the override file?
Create file IdentityController.php in override/controllers/front/.
Now copy the method you are having problem with into this file and comment line with faulty code.
You also want to delete file tools/smarty/index.php to force smarty template recompilation! (Rookie mistake)
For your information, this notice is thrown because you are trying to access variable named "active" of object that does not exist.
This is accessing public attribute:
$instance = new Module;
$instance->active;
This is calling public static method of class Module:
Module::getInstanceByName('blocknewsletter');
In this call no object is really created because non is needed.
Thankfully passing non-existing variable into smarty template isn't fatal error and application can keep running ignoring this mistake.