Jump to content

Problem with custom field for products Prestashop 1.7.2


shekhar.patil

Recommended Posts

Having some issue while saving the value of the custom field added in products edit page (Backoffice).

I have done things in following order:

1.  Added the custom field (Boolean) in Products table (database).

2. Override the product class and added the definition for the custom field.

3. Added the custom field in the ProductInformation.tpl

4. Added the field in the form.html.twig.

Problem: I'm able to see the checkbox on the products edit page from Backoffice. Also, it is not checked as the default value for the field is FALSE.

But unable to update the value of the field on Save button. 

Other things like product name or price are updating properly but the custom field value remains the same.

Please help!!! :(

 

Link to comment
Share on other sites

@shekhar.patil 

As per the points that you have mentioned, it seems that you have missed the logic to save the value of the custom field in the DB, you are supposed to add the logic to Admin Product controller (/controllers/admin/AdminProductsController.php) for the same.

P. S. Just an advice, you should not be editing the table structure of the core Product table to add a custom field to the product form, you can simply create another custom table to save the data and then use hooks to add the field and save its values.

Link to comment
Share on other sites

On 22/12/2017 at 1:36 PM, Knowband Plugins said:

@shekhar.patil 

As per the points that you have mentioned, it seems that you have missed the logic to save the value of the custom field in the DB, you are supposed to add the logic to Admin Product controller (/controllers/admin/AdminProductsController.php) for the same.

P. S. Just an advice, you should not be editing the table structure of the core Product table to add a custom field to the product form, you can simply create another custom table to save the data and then use hooks to add the field and save its values.

 

Hi, Thanks for the reply. 

I have no idea how to do that. 

Can you plz explain in more detail. 

 

 

Link to comment
Share on other sites

  • 5 weeks later...

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