I am facing a strange situation. I am trying to override cart controller and I am able to succeed if I place the CartController.php
file in /override/controllers/front and fails if I place the same file in my custom module and installing the module. The path of file in module is myModule/override/controllers/front. The file contents are
class CartController extends CartControllerCore
{
public function init()
{
die('Override');
}
}
I have also registered a hook and it displays fine.
public function install()
{
if (Shop::isFeatureActive())
Shop::setContext(Shop::CONTEXT_ALL);
return parent::install() && $this->registerHook('Test');
}
public function uninstall()
{
if (!parent::uninstall() ||
!Configuration::deleteByName('MYMODULE_NAME'))
return false;
return true;
}
public function hookTest($params){
return $this->display(__FILE__, '/views/templates/hook/testpage.tpl');
}
What am I missing here?
I believe you are doing everthing ok. The override in your module is copied to the override folder/file when you install the module, unless there is already another override for that class function. See this answer https://stackoverflow.com/a/24114184