Woocommerce -> MySQL -> vVariationMetaData vProductVariation

20181220 Product variations (attribute = length only currently)

alter view vVariationMetaData
as
-- 20181220 LSR
-- Product Variations meta data
-- Note is selected metadata only (not quite all)
select po.post_parent, pm.post_id
,max(case when meta_key = 'attribute_length' then meta_value else null end) as pvm_attribute_length
,max(case when meta_key = '_sku' then meta_value else null end) as pvm_sku
,max(case when meta_key = '_weight' then meta_value else null end) as pvm_weight
,max(case when meta_key = '_length' then meta_value else null end) as pvm_length
,max(case when meta_key = '_width' then meta_value else null end) as pvm_width
,max(case when meta_key = '_height' then meta_value else null end) as pvm_height
,max(case when meta_key = '_manage_stock' then meta_value else null end) as pvm_manage_stock
,max(case when meta_key = '_regular_price' then meta_value else null end) as pvm_regular_price
,max(case when meta_key = '_price' then meta_value else null end) as pvm_price
,max(case when meta_key = '_variation_description' then meta_value else null end) as pvm_variation_description
from wp1_postmeta pm
join wp1_posts po on po.ID = pm.post_id
where po.post_type = 'product_variation'
group by po.post_parent, pm.post_id;


alter view vProductVariations
as
-- 20181220 LSR
-- Product meta data
select ID, post_title, pm_sku, pvm.*
from vProductMetaData pm
join vVariationMetaData pvm on pvm.post_parent = pm.id
order by pm.ID, pvm_attribute_length*0;

xx