piR-web 0 Posted October 1, 2017 Posted October 1, 2017 (edited) Bonjour, Je viens d'intégrer un champ texte dans la table Specific Price et je souhaite mettre à jour ma base de donnée lorsque le champ est modifier : Voici le code que j'ai intégré mais il ne fonctionne pas : if(isset($_POST['marquage_promo'])) { $sql = "SELECT * FROM "._DB_PREFIX_."specific_price WHERE id_product=".(int)$id_product; $res=Db::getInstance()->ExecuteS($sql); $marquage_promo = $_POST['marquage_promo']; if (count($res)) { if ($marquage_promo) { $sql = "UPDATE "._DB_PREFIX_."specific_price SET marquage_promo=".$marquage_promo." WHERE id_product=".(int)$id_product; Db::getInstance()->Execute($sql); }else{ $sql = "DELETE mon_champ FROM "._DB_PREFIX_."specific_price WHERE id_product=".(int)$id_product; Db::getInstance()->Execute($sql); } }else{ $sql = "INSERT INTO "._DB_PREFIX_."specific_price (id_product,marquage_promo) VALUES (".(int)$id_product.",".$marquage_promo.")"; Db::getInstance()->Execute($sql); } } Pouvez-vous m'aider ? Merci beaucoup Edited October 2, 2017 by piR-web (see edit history) Share this post Link to post Share on other sites
okom3pom 682 Posted October 2, 2017 Posted October 2, 2017 Bonjour,OMG la faille de sécurité Ensuite regarder dans le forum ou sur google comment ajouter proprement un champ à une table prestashop le plus souvent ( ajouter un champ à la table product prestashop ) Ensuite ça donne quelque chose comme : if( Tools::getValue('id_specific_price') && Tools::getValue('marquage_promo') ) { $specifiqueprice = new SpecificPrice( (int)Tools::getValue('id_specific_price') ) // Ici du Validate pour voir si ça existe bien $specifiqueprice->marque_promo = pSQL(Tools::getValue('marquage_promo')); $specifiqueprice->save(); } Un produit peu avoir plusieurs prix spécifique Share this post Link to post Share on other sites
okom3pom 682 Posted October 2, 2017 Posted October 2, 2017 Mais si tu as bien ajouté le champ à l'objet le code ne sert à rien dans l'admin ça se fera tout seul Share this post Link to post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now