PrestaShop icon indicating copy to clipboard operation
PrestaShop copied to clipboard

CustomizationField::is_module flag gets reset after a product save

Open musaffarpatel opened this issue 1 year ago • 3 comments

Prerequisites

Describe the bug and add attachments

The bug related to the database table ps_cusotmization_field. If an entry is present in the table with the "is_module" column set to 1, this seems to get reset to 0 whenever the product is saved after editing in the back office. This causes issues for modules which utilize the customization_field table.

This seems to affect more recent versions of Prestashop, at least from 8.1.3 onwards but not tested on earlier versions.

Expected behavior

The existing value for "is_module" should not be overwritten

Steps to reproduce

Create an entry in the ps_cusotmization_field table for a product, eg product ID #16 Set the "is_module" column to 1 Not in the back office edit product #16 and save the changes Notice the "is_module" column has been set to 0

PrestaShop version(s) where the bug happened

8.1.3

PHP version(s) where the bug happened

No response

If your bug is related to a module, specify its name and its version

No response

Your company or customer's name goes here (if applicable).

No response

musaffarpatel avatar May 21 '24 09:05 musaffarpatel

Hi @musaffarpatel ,

Thank you for your report, I reproduce the issue with PrestaShop version 8.1.x, as you can see :

recording(221).webm

I'll add this to the backlog so it can be fixed.

Please be aware that some issues might take a very long time to be resolved. If this one is important to you and you cannot wait for it to be fixed on the project’s own time, we strongly suggest you consider contacting a professional to help you.

If you fix the issue on your end, please contribute it back to the project. Remember that the more people contribute, the better PrestaShop becomes for everyone.

Thanks

AureRita avatar May 29 '24 14:05 AureRita

@AureRita Thanks!

musaffarpatel avatar May 29 '24 16:05 musaffarpatel

The problem occurs in the CustomizationFieldsCommandsBuilder::buildCustomizationFields() method

https://github.com/PrestaShop/PrestaShop/blob/1d31acbf2322305b7d1efb1bb7dc2a7776b5eb4f/src/Core/Form/IdentifiableObject/CommandBuilder/Product/CustomizationFieldsCommandsBuilder.php#L69-L80

where the added_by_module field is set to false.

Codencode avatar Jun 14 '24 07:06 Codencode