Jump to content

[Solved]How to debug none working Hooks?


Recommended Posts

I have a hook for one of my modules that worked just fine..
So my question is, how can i debug a not working hook?

use Doctrine\DBAL\Query\QueryBuilder;
use PrestaShop\PrestaShop\Core\Search\Filters\CustomerFilters;

public function install($delete_params = true)
{
	return parent::install() &&
            $this->registerHook('actionCustomerGridQueryBuilderModifier');
}

/**
 * @param array $params
 */
public function hookActionCustomerGridQueryBuilderModifier(array $params)
{
   # My Code
}

If i check the customer list using debug modus, the hook 'actionCustomerGridQueryBuilderModifier' is never hooked from my module.
But if i check 'Appearance > Positions' the hook is active!

How can i debug? Or what am i missing here?
 

Edited by Inform-All (see edit history)

Share this post


Link to post
Share on other sites
4 minutes ago, ndiaga said:

Hi,

Try   to reset  your  module  and add it to that  manually from the positions.

Thank you for your answer!
I've tried this already, did not have a difference, any other ideas? :)

Share this post


Link to post
Share on other sites
2 minutes ago, Inform-All said:

Thank you for your answer!
I've tried this already, did not have a difference, any other ideas? :)

Why  this  variable?  

$delete_params = true

And  try this:

public function install()
    {
        return parent::install()
            && $this->registerHook('actionCustomerGridQueryBuilderModifier')
            
        ;
    }


public function hookActionCustomerGridQueryBuilderModifier($params)
{
   return  'It  works';
}

 

Share this post


Link to post
Share on other sites

the  '$delete_params = true' was indeed not needed anymore, i've deleted it.

And i've tested to return anything before (like you advised 'It works') but nothing, this hook is just not called.
My debug mode does not even show it.

Edited by Inform-All (see edit history)

Share this post


Link to post
Share on other sites

It's the correct hook name according to the docs. I use it to filter out certain customers.
Even if i look into the example docs it should be functioning.

And it does function, but i just have one customer where is does not work that's why i'm wondering how can i debug this?

Share this post


Link to post
Share on other sites
9 minutes ago, Inform-All said:

 

And it does function, but i just have one customer where is does not work that's why i'm wondering how can i debug this?

If  it  works  for other  customers   verify  if the customer  that  it does not for  meet the filter  criterias. 

Share this post


Link to post
Share on other sites
11 minutes ago, ndiaga said:

If  it  works  for other  customers   verify  if the customer  that  it does not for  meet the filter  criterias. 

Thanks, what a rookie mistake! I fixed it.

For people in the future, this might help:
Make sure that if you are using 2 admin profiles, that BOTH profiles have access to the module to make the filter work that you install/use in a module.

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More