-
-
Save phlbnks/e8493fd8e8bd6b2923ca672ab39db205 to your computer and use it in GitHub Desktop.
SELECT | |
wp_posts.post_title AS Product, | |
wp_postmeta1.meta_value AS SKU, | |
wp_postmeta2.meta_value AS Price, | |
GROUP_CONCAT( wp_terms.name ORDER BY wp_terms.name SEPARATOR ', ' ) AS ProductCategories | |
FROM wp_posts | |
LEFT JOIN wp_postmeta wp_postmeta1 | |
ON wp_postmeta1.post_id = wp_posts.ID | |
AND wp_postmeta1.meta_key = '_sku' | |
LEFT JOIN wp_postmeta wp_postmeta2 | |
ON wp_postmeta2.post_id = wp_posts.ID | |
AND wp_postmeta2.meta_key = '_regular_price' | |
LEFT JOIN wp_term_relationships | |
ON wp_term_relationships.object_id = wp_posts.ID | |
LEFT JOIN wp_term_taxonomy | |
ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id | |
AND wp_term_taxonomy.taxonomy = 'product_cat' | |
LEFT JOIN wp_terms | |
ON wp_term_taxonomy.term_id = wp_terms.term_id | |
WHERE wp_posts.post_type = 'product' | |
AND wp_posts.post_status = 'publish' | |
GROUP BY wp_posts.ID | |
ORDER BY wp_posts.post_title ASC |
how bout the stock ? can you add stock list ?
noob question here, i run the query in phpmyadmin, it shows my 1000+ product.
can i edit the price directly from there?
it such a pain to edit from woocomrce
noob question here, i run the query in phpmyadmin, it shows my 1000+ product.
can i edit the price directly from there?
it such a pain to edit from woocomrce
Yes you can. Also you can apply additional filters for specific categories, in order to narrow down the resulset.
it works. thank you
i added 2 more colums
regular_price,
sale_price,
price,
`
SELECT
wpaf_posts.post_title AS Product,
wpaf_postmeta1.meta_value AS SKU,
wpaf_postmeta2.meta_value AS regular_price,
wpaf_postmeta3.meta_value AS sale_price,
wpaf_postmeta4.meta_value AS price,
GROUP_CONCAT( wpaf_terms.name ORDER BY wpaf_terms.name SEPARATOR ', ' ) AS ProductCategories
FROM wpaf_posts
LEFT JOIN wpaf_postmeta wpaf_postmeta1
ON wpaf_postmeta1.post_id = wpaf_posts.ID
AND wpaf_postmeta1.meta_key = '_sku'
LEFT JOIN wpaf_postmeta wpaf_postmeta2
ON wpaf_postmeta2.post_id = wpaf_posts.ID
AND wpaf_postmeta2.meta_key = '_regular_price'
LEFT JOIN wpaf_postmeta wpaf_postmeta3
ON wpaf_postmeta3.post_id = wpaf_posts.ID
AND wpaf_postmeta3.meta_key = '_sale_price'
LEFT JOIN wpaf_postmeta wpaf_postmeta4
ON wpaf_postmeta4.post_id = wpaf_posts.ID
AND wpaf_postmeta4.meta_key = '_price'
LEFT JOIN wpaf_term_relationships
ON wpaf_term_relationships.object_id = wpaf_posts.ID
LEFT JOIN wpaf_term_taxonomy
ON wpaf_term_relationships.term_taxonomy_id = wpaf_term_taxonomy.term_taxonomy_id
AND wpaf_term_taxonomy.taxonomy = 'product_cat'
LEFT JOIN wpaf_terms
ON wpaf_term_taxonomy.term_id = wpaf_terms.term_id
WHERE wpaf_posts.post_type = 'product'
AND wpaf_posts.post_status = 'publish'
GROUP BY wpaf_posts.ID
ORDER BY wpaf_posts.post_title ASC
`
Thanks you! ❤