trying to fetch products from wooocommerce to script with sql, but have no luck in it. tried that:
$query = "SELECT
p.id, p.post_title as title, pm.meta_value as price
FROM wp_posts p
LEFT JOIN
wp_term_relationships tr
ON
p.ID = tr.object_id
LEFT JOIN
wp_term_taxonomy tt
ON
tr.term_taxonomy_id = tt.term_taxonomy_id
LEFT JOIN
wp_terms t
ON
t.term_id = tt.term_id
and tt.term_id = t.term_id
LEFT JOIN wp_postmeta pm
ON
p.ID = pm.post_id
and pm.meta_key = 'price'
WHERE
1
and tt.taxonomy = 'product_type'
and t.name = %s
AND post_type = 'product'
AND post_status = 'publish'
GROUP BY p.id
"
but had no product. what should i do to fetch products with sql in woocomerce?