Cocob35 Posted January 10, 2019 Share Posted January 10, 2019 (edited) bonjour, j'ai créer deux nouvelles boutiques (multiboutiques, presta 1.7.4.4) et je souhaiterai activer toutes les catégories (et sous catégo) pour ces deux boutiques automatiquement. Je ne trouve pas comment faire, quelqu'un a-t-il une piste ? Amicalement, Johann Edited January 20, 2019 by Cocob35 (see edit history) Link to comment Share on other sites More sharing options...
doekia Posted January 10, 2019 Share Posted January 10, 2019 (edited) -- insert ignore into ps_category_shop select c.id_category, s.id_shop, 1 from ps_category c inner join ps_shop s on 1=1 where c.id_parent != 0 NON testé, FAIRE un BACKUP de la table avant Edited January 19, 2019 by doekia (see edit history) Link to comment Share on other sites More sharing options...
Cocob35 Posted January 14, 2019 Author Share Posted January 14, 2019 On 1/10/2019 at 5:11 PM, doekia said: -- insert ignore into ps_category_shop select c.id_category, s.id_shop, 1 from ps_category c inner join ps_shop s on 1=1 where c.parent != 0 NON testé, FAIRE un BACKUP de la table avant bonjour doekia, je dois faire un copier coller tel quel de ce code dans phpmyadmin ? Amicalement, Johann Link to comment Share on other sites More sharing options...
Cocob35 Posted January 14, 2019 Author Share Posted January 14, 2019 J'ai tester avec phpmysql, et j'ai ce message MySQL a répondu : #1054 - Champ 'c.parent' inconnu dans where clause Link to comment Share on other sites More sharing options...
doekia Posted January 19, 2019 Share Posted January 19, 2019 coquille: c.id_parent Link to comment Share on other sites More sharing options...
Cocob35 Posted January 19, 2019 Author Share Posted January 19, 2019 (edited) Cela n'a pas fonctionné, le script fonctionne, mais cela ne passe pas toute les catégories actives pour toutes les boutiques voici un extrait du résultat en PJ et le script que j'ai utiliser dans phpmyadmin -- insert ignore into mod123_category_shop select c.id_category, s.id_shop, 1 from mod123_category c inner join mod123_shop s on 1=1 where c.id_parent != 0 Amicalement, Johann Edited January 19, 2019 by Cocob35 (see edit history) Link to comment Share on other sites More sharing options...
doekia Posted January 19, 2019 Share Posted January 19, 2019 Disons que quand je lâche du code apte à bousiller un shop, je m'arrange justement pour que mon code ne fasse rien.... Cherche c'est pas compliqué... Mais ce sera. Ta responsabilité Link to comment Share on other sites More sharing options...
Cocob35 Posted January 20, 2019 Author Share Posted January 20, 2019 (edited) OK c'est le jeu de l'aide mystérieuse, 😂 Dans ce cas peut-être que le code ne modifie pas, mais affiche simplement le résultat de ce qu'il ferait, un aperçu avant travaux en somme. En effet le statut passe bien à 1 partout (0 pour inactif, et 1 pour actif je suppose) Bon donc comment valider le résultat dans ce cas, Je pense que c'est l'instruction -- insert ignore https://stackoverflow.com/questions/548541/insert-ignore-vs-insert-on-duplicate-key-update Donc est-ce que le code serait dans ce cas ? -- insert into mod123_category_shop select c.id_category, s.id_shop, 1 from mod123_category c inner join mod123_shop s on 1=1 where c.id_parent != 0 merci pour ton aide, Amicalement, Johann Edited January 20, 2019 by Cocob35 (see edit history) Link to comment Share on other sites More sharing options...
Eolia Posted January 20, 2019 Share Posted January 20, 2019 Tu y es presque^^ Link to comment Share on other sites More sharing options...
Cocob35 Posted January 20, 2019 Author Share Posted January 20, 2019 17 minutes ago, Eolia said: Tu y es presque^^ allez un petit indice s'il te plait 😏 Link to comment Share on other sites More sharing options...
Eolia Posted January 20, 2019 Share Posted January 20, 2019 Comment commenter une ligne en SQL ? Link to comment Share on other sites More sharing options...
Cocob35 Posted January 20, 2019 Author Share Posted January 20, 2019 dans ce cas le code serait soit : insert into mod123_category_shop select c.id_category, s.id_shop, 1 from mod123_category c inner join mod123_shop s on 1=1 where c.id_parent != 0 ou alors dois-je garder le ignore ? et dans ce cas le code serait : insert ignore into mod123_category_shop select c.id_category, s.id_shop, 1 from mod123_category c inner join mod123_shop s on 1=1 where c.id_parent != 0 je penche pour la seconde solution. 😋 Amicalement, Johann Link to comment Share on other sites More sharing options...
Eolia Posted January 20, 2019 Share Posted January 20, 2019 Ben si tu ne laisses pas l'ignore le code va crasher en cas de duplicate^^ Dans tous les cas, sauvegarder la table mod123_category_shop avant, ça peut être utile... Link to comment Share on other sites More sharing options...
Cocob35 Posted January 20, 2019 Author Share Posted January 20, 2019 Ça marche, merci à Eolia pour son aide précieuse ! donc pour résumer le code à utiliser est : poru faire un test et voir ce qui va être modifier, sans modification dans la base de données : -- insert ignore into mod123_category_shop select c.id_category, s.id_shop, 1 from mod123_category c inner join mod123_shop s on 1=1 where c.id_parent != 0 et pour modifier la base de données en écriture : insert ignore into mod123_category_shop select c.id_category, s.id_shop, 1 from mod123_category c inner join mod123_shop s on 1=1 where c.id_parent != 0 Amicalement, Johann Link to comment Share on other sites More sharing options...
Eolia Posted January 20, 2019 Share Posted January 20, 2019 Surtout merci à @doekia pour la requête fournie^^ Link to comment Share on other sites More sharing options...
Cocob35 Posted January 20, 2019 Author Share Posted January 20, 2019 5 hours ago, Eolia said: Surtout merci à @doekia pour la requête fournie^^ oui pardon merci à doekia pour son aide Amicalement, Johann Link to comment Share on other sites More sharing options...
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