问题
I'm trying to override the AdminCarriersControllerCore, specifically the postProcess method (so that it updates the carrier instead of deleting and creating a new one, because it breaks reference).
To check that it get's overriden first i do:
<?php
class AdminCarriersController extends AdminCarriersControllerCore
{
public function __construct(){
die(var_dump('constructor'));
}
}
I've put it in the following path
modules/<my_module_name>/override/controllers/admin/AdminCarriersController.php
It doesn't overrides.
Also tried in:
modules/<my_module_name>/controllers/admin/AdminCarriersController.php
Also deleted the cache file (which didn't get regenerated automatically as the docs say)
rm class_index.php
Thanks for any help. Official Prestashop docs page for overriding
Note: Yes, I'm aware that there is a reference_id or whatever and that I shouldn't use the carrier_id directly, but the module is already too cryptic and trying to change the carrier_id to the correct one is too risky and too much time-consuming.
回答1:
Placing override files in your module_name/override
does not do anything yet. When installing a module, PrestaShop will check if you have override files in your module and do a check if your overriden class has methods already overriden by another module. If it does, then you won't be able to install the module.
If you have module already installed and you can't reinstall it for some reason then you need to place override file directly into root override
folder and delete
file cache/class_index.php
.
I'm not sure if override files get installed with a module upgrade. I'll check it later and update the answer.
来源:https://stackoverflow.com/questions/49947782/prestashop-1-6-override-admin-controller-not-overriding