Last active
August 7, 2023 13:52
-
-
Save mglaman/8406244 to your computer and use it in GitHub Desktop.
MySQL query for wooCommerce to export products.
This file contains hidden or 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 product.ID as product_id, product.post_title as product_name, replace(product.post_content, '"', "'") as product_content, product_sku.meta_value as product_sku, product_price.meta_value as product_price, product_weight.meta_value as product_weight | |
FROM wp_posts as product | |
LEFT JOIN wp_postmeta as product_sku ON product.ID = product_sku.post_ID | |
LEFT JOIN wp_postmeta as product_price ON product.ID = product_price.post_ID | |
LEFT JOIN wp_postmeta as product_weight ON product.ID = product_weight.post_ID | |
WHERE (product.post_type = 'product' OR product.post_type = 'product_variation') AND product_sku.meta_key = '_sku' AND product_price.meta_key = '_price' AND product_weight.meta_key = '_weight' | |
ORDER BY product_id ASC |
@mglaman thanks
How would I got about adding a specific product attribute to this query
I would like to know this also.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I get the Product title, Product SKU and Product Price in a single sql query containing only one JOIN...?