Jump to content

Using prestashop 1.7 hooks problem


Andrei Dinca

Recommended Posts

Hi,

I need to modify the "fields_value" from products edit page.

How can I use: action<AdminControllerName>FormModifier on my custom module for doing this? I've tried to use the hook like: "actionAdminProductsFormModifier" or "actionProductControllerFormModifier" but with no luck.

Any help?

Thanks.

Link to comment
Share on other sites

You have to check those hooks exists in the database first, because it's not always the case.

 

Perosnnally I had to run this PHP code (just once):

$db = Db::getInstance();
$sqls = [
'insert into '.$db->getPrefix().'hook (name, title, position, description) values ("actionAdminProductsListingFieldsModifier", "actionAdminProductsListingFieldsModifier", 1, "")', // ajout hook category
'insert into '.$db->getPrefix().'hook (name, title, position, description) values ("actionAdminCustomersControllerSaveAfter", "actionAdminCustomersControllerSaveAfter", 1, "")', // ajout hook customers
'insert into '.$db->getPrefix().'hook (name, title, position, description) values ("actionAdminCategoriesFormModifier", "actionAdminCategoriesFormModifier", 1, "")', // ajout hook category BO
'insert into '.$db->getPrefix().'hook (name, title, position, description) values ("actionAdminCategoriesControllerSaveAfter", "actionAdminCategoriesControllerSaveAfter", 1, "")', // ajout hook category BO
];
foreach ($sqls as $sql) {
  $res = $db->execute($sql);
  if(!$res){
  	throw new \Exception("Error Processing SQL $sql", 1);
  }
}

 

Edited by Florian (see edit history)
Link to comment
Share on other sites

  • 2 years later...
On 2/27/2018 at 5:24 PM, Florian said:

You have to check those hooks exists in the database first, because it's not always the case.

 

Perosnnally I had to run this PHP code (just once):


$db = Db::getInstance();
$sqls = [
'insert into '.$db->getPrefix().'hook (name, title, position, description) values ("actionAdminProductsListingFieldsModifier", "actionAdminProductsListingFieldsModifier", 1, "")', // ajout hook category
'insert into '.$db->getPrefix().'hook (name, title, position, description) values ("actionAdminCustomersControllerSaveAfter", "actionAdminCustomersControllerSaveAfter", 1, "")', // ajout hook customers
'insert into '.$db->getPrefix().'hook (name, title, position, description) values ("actionAdminCategoriesFormModifier", "actionAdminCategoriesFormModifier", 1, "")', // ajout hook category BO
'insert into '.$db->getPrefix().'hook (name, title, position, description) values ("actionAdminCategoriesControllerSaveAfter", "actionAdminCategoriesControllerSaveAfter", 1, "")', // ajout hook category BO
];
foreach ($sqls as $sql) {
  $res = $db->execute($sql);
  if(!$res){
  	throw new \Exception("Error Processing SQL $sql", 1);
  }
}

 

Thanks, I just found what I need in the database

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...