Woocommerce -> MySQL -> vProductType / vProductCategoriesConcat

Quick and dirty as needed for stock take calculations

create view vProductType AS
 select po.ID, te.slug as product_type
 from wp1_posts po
 JOIN wp1_term_relationships tr ON po.ID = tr.object_id
 JOIN wp1_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
 JOIN wp1_terms te ON tt.term_id = te.term_id
 WHERE po.post_type = 'product'
 AND tt.taxonomy = 'product_type';

Product categories, note a few products are in multiple categories hence the group_cat

create view vProductCategoriesConcat AS
 select po.ID, group_concat(te.name, ',') as catname
 from wp1_posts po
 JOIN wp1_term_relationships tr ON po.ID = tr.object_id
 JOIN wp1_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
 JOIN wp1_terms te ON tt.term_id = te.term_id
 WHERE po.post_type = 'product'
 AND tt.taxonomy = 'product_cat'
 group by po.ID;

xxxx