Jump to content

How to develop module that adds an additional field on product


Recommended Posts

Hi Folks,

Last hours I searched internet for tutorials or documentations on how to develop modules for PrestaShop.
I am running a PrestaShop and I try to understand how everything works.
I understand how to change existing pages,... But I try to do changements with a own module.

My idea to learn how it works is, to just add an simple field on back admin for products to set an value of 0-100 on a newly added database field.
I managed to set up the module and to modify the database

Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'product`  ADD `v_expiry` SMALLINT(3) NOT NULL AFTER `upc`');

But I wasn't able to understand how to add a new input field to the product administration page (options, where EAN,... are set)
I think it is on hook: hookDisplayAdminProductsExtra, right?

But how to add that field now? And how can I trigger that value in that field gets saved in database?

 

Does anyone have a link to a fitting Tutorial?
Or can explain it to me?

I'm sure that there will be an answer in world wide web - but I think I was to stupid to find it - sorry...

 

 


 

Link to comment
Share on other sites

Well, problem solved.

Meanwhile I've found this tutorial:
http://nemops.com/prestashop-products-new-tabs-fields/#.Xn41onJCdhE

The script isn't realy working, but it helped me understanding how it works.

In addition with this list:
https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/ 
Needed hooks can be found...

At moment just strugling with showing content on displayProductExtraContent  (nothing appears).
But I will solve that 😉

EDIT: Well, also this problem solved. Just reseting Module dosn't update hooks on front end. Needed to deinstall and newly install it...

Edited by Chrigu
solved (see edit history)
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...