jdanthinne / advancedfeaturesvalues

Prestashop module to enable multiple values selection for features, and features values ordering.
GNU General Public License v2.0
38 stars 20 forks source link

Customized value is not working (not saving) #28

Closed ilyasovivan closed 5 years ago

ilyasovivan commented 6 years ago

Prestashop 1.6.1.18 Information from Prestashop forum about this issue: "When I try to fill customized value, when there is already pre-defined ones, then it simply dont save to DB. When there is no pre-defined values, then cutomized value works fine."

Screencast

ilyasovivan commented 6 years ago

Problem with name="feature_{$available_feature.id_feature|intval}_value[]" Customized value is not array [].

And I found another small bug. If the Customized Value is filling, the Pre-Defined values are not clearing. Solution for this small issue: onchange="$('custom{$available_feature.idfeature|intval}).val('');">_ to onchange="$('[class^=custom{$available_feature.idfeature|intval}]').val('');">_

jdanthinne commented 6 years ago

Feel free to submit PR.

joeri210 commented 5 years ago

Problem is that empty variables are not being sent anymore with PHP. So the loop through features if not selected, will fail if not selected (thus custom). Solution is to loop through the custom fields instead.

File: override/controllers/admin/AdminProductsController.php

Replace (line 100): if (preg_match('/^feature_([0-9]+)_value/i', $key, $match)) { For: if (preg_match('/^custom_([0-9]+)_([0-9]+)/i', $key, $match)) { $val = $_POST['feature_'. $match[1] . '_value'];

As always, backup first!