Last active
April 22, 2019 18:20
-
-
Save web-hat/d65e14093398e8036f4fa36a63dfbdf5 to your computer and use it in GitHub Desktop.
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
SELECT p.`ID` AS 'Product ID', | |
p.`post_title` AS 'Product Name', | |
t.`term_id` AS 'Attribute Value ID', | |
REPLACE(REPLACE(tt.`taxonomy`, 'pa_', ''), '-', ' ') AS 'Attribute Name', | |
t.`name` AS 'Attribute Value' | |
FROM `wp_posts` AS p | |
INNER JOIN `wp_term_relationships` AS tr ON p.`ID` = tr.`object_id` | |
INNER JOIN `wp_term_taxonomy` AS tt ON tr.`term_taxonomy_id` = tt.`term_id` | |
AND tt.`taxonomy` LIKE 'pa_%' | |
INNER JOIN `wp_terms` AS t ON tr.`term_taxonomy_id` = t.`term_id` | |
WHERE p.`post_type` = 'product' | |
AND p.`post_status` = 'publish' | |
ORDER BY p.`ID` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full article in https://www.webhat.in/article/woocommerce-tutorial/how-product-attribute-are-stored-in-database/