Ayush
Ayush

Reputation: 812

Prestashop module development: How can we save data from product page?

I'm here for help from those who have real experience in Prestashop module development.

I got stucked while saving data from the product page where I've created the field through the module via hookDisplayAdminProductsExtra.

And I didn't get an idea to save new field data from the admin product page.

So, please help if anyone has a solution for this.

Thank You.

Upvotes: 0

Views: 703

Answers (1)

gennaris
gennaris

Reputation: 1612

Add a form in your hook returned TPL, so that you can retrieve and save your custom data in DB by registering and triggering "actionProductUpdate" in the module (this hook is called when a product is saved) by using Tools::getValue() inside the hook on your POST data.

Other solution would be to save data in AJAX with a dedicated AdminController - You can insert a custom button in your TPL + an additional JS file (you can include it with hookBackofficeHeader) to trigger the AJAX call. You can see more about AdminController in official devdocs.

Upvotes: 1

Related Questions