Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select a.sku, a.name, group_concat(attributes.name SEPARATOR '\t'),
- group_concat((case when attributes.value_type = 'multiple_select' then
- COALESCE((select group_concat(
- concat(o.value,COALESCE(concat(" ",(select code from product_units where id = o.unit_id)),""))
- ) from product_attribute pa
- JOIN tblIndex
- join attribute_options o on o.id = (SUBSTRING_INDEX(SUBSTRING_INDEX(pa.value, ',', ntIndex), ',', -1))
- and ntIndex <= 1 + LENGTH(pa.value) - LENGTH(REPLACE(pa.value,',',''))
- where pa.product_id = a.id and pa.attribute_id = attributes.id
- ),"")
- ELSE
- COALESCE((select (case when attributes.value_type = "text" then
- concat(pa.value,COALESCE(concat(" ",(select code from product_units where id = pa.unit_id)),""))
- else
- concat(o.value,COALESCE(concat(" ",(select code from product_units where id = o.unit_id)),""))
- end) from product_attribute pa
- left join attribute_options o on pa.value = o.id
- where pa.product_id = a.id and pa.attribute_id = attributes.id
- ),"") end) SEPARATOR '\t')
- from products a join attribute_groups e on a.attribute_set_id = e.attribute_set_id
- join attribute_group_attribute d on d.attribute_group_id = e.id
- join attributes on d.attribute_id = attributes.id
- where a.attribute_set_id = 15 and a.seller_id = 1
- and a.created_at > '2020-02-05'
- group by a.sku
- limit 1000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement