theillo Posted June 13, 2020 Share Posted June 13, 2020 (edited) According to https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/ there is a hook called action<AdminControllerName>ListingFieldsModifier I would like to use this hook, but in order to do so, I need to debug, to find out what the parameters are, etc. So then I go into /classes/controller/AdminController.php to public function getList() in line 3153 There, the following code does nothing: public function getList( $id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false ) { //// THIS IS THE CODE I'VE INSERTED/// dump($this->controller_name); die(); //// END OF MY OWN CODE/// Hook::exec('action' . $this->controller_name . 'ListingFieldsModifier', array( 'select' => &$this->_select, 'join' => &$this->_join, 'where' => &$this->_where, 'group_by' => &$this->_group, 'order_by' => &$this->_orderBy, 'order_way' => &$this->_orderWay, 'fields' => &$this->fields_list, )); The page is loading as if nothing ever happened. How can I debug anything in this function, when die() and dump() don't do anything? Edited June 13, 2020 by theillo (see edit history) Link to comment Share on other sites More sharing options...
Janett Posted June 13, 2020 Share Posted June 13, 2020 https://symfony.com/doc/current/components/var_dumper.html#the-dump-function Link to comment Share on other sites More sharing options...
theillo Posted June 13, 2020 Author Share Posted June 13, 2020 Thanks for the reply! Yes, I'm using the dump function, see my code... What am I doing wrong? Usually, dump(); die(); works perfect, but in this specific case it doesn't seem to do anything. Seems to straight up ignore it. Link to comment Share on other sites More sharing options...
Janett Posted June 13, 2020 Share Posted June 13, 2020 What controller would you debug ? If it's a Symfony controller your code will not be called. Link to comment Share on other sites More sharing options...
theillo Posted June 13, 2020 Author Share Posted June 13, 2020 Is the AdminController a Symfony controller? I think not, right...? Link to comment Share on other sites More sharing options...
Janett Posted June 14, 2020 Share Posted June 14, 2020 What is the name of controller you want debug ? AdminController is only used by legacy controller, modern controllers use Symfony and are located here : https://github.com/PrestaShop/PrestaShop/tree/develop/src/PrestaShopBundle/Controller/Admin Link to comment Share on other sites More sharing options...
theillo Posted June 14, 2020 Author Share Posted June 14, 2020 (edited) What the actual firetruck? Then why in the hell would the documentation point me to /classes/controller/AdminController.php where the Hook gets called that I wanna use? I'm so lost right now So where is the action<AdminControllerName>ListingFieldsModifier Hook located in a "modern" controller? Where does it get called, so I can hook into it? Edited June 14, 2020 by theillo (see edit history) Link to comment Share on other sites More sharing options...
theillo Posted June 14, 2020 Author Share Posted June 14, 2020 (edited) What the actual F? Then why in the world would the documentation point me to /classes/controller/AdminController.php where the Hook gets called that I wanna use? I'm so lost right now So where is the action<AdminControllerName>ListingFieldsModifier Hook located in a "modern" controller? Where does it get called, so I can hook into it? Edited June 14, 2020 by theillo (see edit history) Link to comment Share on other sites More sharing options...
Janett Posted June 14, 2020 Share Posted June 14, 2020 If you tell me the name of the page in your PrestaShop BO you want debug, I can tell you where to see. 1 Link to comment Share on other sites More sharing options...
theillo Posted June 14, 2020 Author Share Posted June 14, 2020 index.php/sell/catalog/categories I want to add a column to the category list using the hook actionAdminCategoryListingFieldsModifier but I don't even know yet if it's called actionAdminCmsCCategoryListingFieldsModifier or something else. But that's not going to be a very sustainable method for me to keep developing, if I need to ask you where to find the hooks... What happened to the documentation? Has version 1.8 been released, and the 1.7 documentation is no longer valid? I'm using 1.7.6.5 by the way, which I've downloaded approximately one month ago... Link to comment Share on other sites More sharing options...
Janett Posted June 14, 2020 Share Posted June 14, 2020 Ok the Category controller has been migrated to Symfony so your code is not called : You should follow this documentation, it’s an example for Customer controller but it work like Category controller https://devdocs.prestashop.com/1.7/modules/sample-modules/grid-and-identifiable-object-form-hooks-usage/ Link to comment Share on other sites More sharing options...
theillo Posted June 14, 2020 Author Share Posted June 14, 2020 Ok. Thanks for the link, this should probably work. But man, I'm pissed. I'm in the process of upgrading from 1.6 to 1.7 and now you're telling me the documentation for 1.7 is outdated, because there was a major change in the architecture from 1.7.something to 1.7.6 ? Who's in charge of versioning at PrestaShop? Who's in charge of making sure that any changes are backwards compatible with the documentation? Link to comment Share on other sites More sharing options...
Janett Posted June 14, 2020 Share Posted June 14, 2020 https://build.prestashop.com/news/a-more-semantic-versioning-scheme/ Link to comment Share on other sites More sharing options...
theillo Posted June 14, 2020 Author Share Posted June 14, 2020 Well, SemVer has clearly been violated if the hooks that are documented under 1.7 are no longer backwards compatible with a subversion of 1.7 https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/ This documentation tells me that in version 1.7 I have a hook available, called action<AdminControllerName>ListingFieldsModifier But according to everything you've told me here, this 1.7 API is no longer backwards compatible in 1.7.6.5 because the hook no longer gets called, because of a merge to Symfony or whatever. "MINOR version when you add functionality in a backwards-compatible manner" Functionality was added, but not in a backwards compatible manner, because documented functionality was removed. So if I'm understanding everything correctly, 1.7.6.5 should really be called 1.8 Link to comment Share on other sites More sharing options...
Janett Posted June 14, 2020 Share Posted June 14, 2020 https://build.prestashop.com/news/prestashop-in-2019-and-beyond-part-2-pain-points/ 1 Link to comment Share on other sites More sharing options...
theillo Posted June 14, 2020 Author Share Posted June 14, 2020 Quote Before continuing, it’s important to say that following this release and between 2016 and 2018, most of the original team that developed PrestaShop 1.7 left the company or was reassigned. That explains the high number of WTFs per minute............ Thanks this is a great article, allowing me to make a more educated decision about how to move forward with my upgrade. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now