Passer la navigation

Il s'agit du forum d'assistance technique de WPML, le plug-in multilingue pour WordPress.

Il est accessible à tous, toutefois seuls les clients de WPML peuvent y publier leurs messages. L'équipe du WPML répond sur le forum 6 jours par semaine, 22 heures par jour.

Sun Mon Tue Wed Thu Fri Sat
- 6:00 – 12:00 8:00 – 12:00 6:00 – 12:00 8:00 – 12:00 6:00 – 12:00 -
- 13:00 – 15:00 13:00 – 17:00 13:00 – 15:00 13:00 – 17:00 13:00 – 15:00 -

Fuseau horaire du support : America/Lima (GMT-05:00)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par Nicolas V. Il y a 1 année et 8 mois.

Assisté par: Nicolas V..

Auteur Messages
octobre 4, 2023 à 11:35 am #14512421

stephaneF-12

hello please give me the sql command to mass delete all products of a language

octobre 4, 2023 à 1:47 pm #14513595

Nicolas V.
Supporter

Les langues: Anglais (English ) Français (Français )

Fuseau horaire: America/Lima (GMT-05:00)

Hello,

Welcome to the WPML support forum. I would first start by saying that deleting products directly from the database can be messy because you have to delete information stored in different tables: the post itself, all post metas, the translation tables, plus any other things that third party plugins could add. So, you may have a lot of "leftovers/orphans" to clean up.

The easiest way would be to use the WordPress interface:
- Go to "Products" in your dashboard,
- Switch to the targeted language and them select all products and delete them
- Note that you can use the "Screen options" at the top of your screen to increase the number of products per page from 20 to 100 (or more if you have a good server)

Else you could write a PHP code that use "wp_delete_post" because that will delete not only the posts but all the post metas (and I think it will also delete the entries in the translation tables). Custom code is out of the scope of our support and I would recommend to make a full backup of your database first.

octobre 4, 2023 à 4:30 pm #14514893

stephaneF-12

Hello, I will explain our situation in details.

We have a Woocommerce store and we use WPML as our translation plugin. we added 14 languages. we notice that the website is getting slower and also our server is showing that wpml queries take long to execute.

now what we want to do is reduce the languages form 14 to 7 languages. the number of products is big so we can't delete them 50 by 50 we need to remove the at once, and the better way to do it is with SQL. we need to remove them completly from the database aswell.

so my question is; can you provide us with SQL requete that will remove all the content of a language (AR for example) from the database.

Screenshot 2023-10-04 at 17.24.21.png
octobre 5, 2023 à 2:16 pm #14521039

Nicolas V.
Supporter

Les langues: Anglais (English ) Français (Français )

Fuseau horaire: America/Lima (GMT-05:00)

Hi,

Thanks for the explanation. In that case I have an easier way to do it.
- Go to "WPML > Languages > Site Languages" and click on "Add/Remove languages"
- Remove the languages you desire
- A new table with all the content from those removed languages will appear and ask you if you want to delete them from your database.

See screenshot.

screenshot-2023.10.05-09_14_43.png

Le sujet « [Fermé] remove all product with sql » est fermé aux nouvelles réponses.