Created
January 20, 2022 14:23
-
-
Save nicomollet/473c4512123c084ae5f04058f0afd81e to your computer and use it in GitHub Desktop.
WooCommerce most/least sold products Mysql query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exclude product variations since they don't include the "total_sales" meta key filled by WooCommerce | |
SELECT ID, post_title, post_status, post_modified, meta_value | |
FROM wp_posts | |
INNER JOIN wp_postmeta ON wp_postmeta.post_id=wp_posts.ID | |
AND wp_postmeta.meta_key='total_sales' | |
WHERE post_type='product' | |
ORDER BY CAST(`wp_postmeta`.`meta_value` as UNSIGNED) DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment