Jump to content

Debug AdminController to use hook ListingFieldsModifier


Recommended Posts

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 by theillo (see edit history)
Link to comment
Share on other sites

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

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 by theillo (see edit history)
Link to comment
Share on other sites

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 by theillo (see edit history)
Link to comment
Share on other sites

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...