Advertisement
wiby15

report_master_product

Nov 4th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.88 KB | None | 0 0
  1. CREATE view report_master_product as
  2. select
  3.     cpvfd.variation_id as 'Variation Id',
  4.     cpvfd.product_id as 'Product Id',
  5.     cpfd.`type` as 'Type',
  6.     c.name as 'Brand',
  7.     cpvfd.title as 'Title',
  8.     sub.category as 'Category',
  9.     principal.name as 'Principal',
  10.     if(cpvfd.status, 'Published', 'Unpublished') as 'Status',
  11.     cpvdimensions.dimensions_length as 'Dimension Length',
  12.     cpvdimensions.dimensions_width as 'Dimension Width',
  13.     cpvdimensions.dimensions_height as 'Dimension Height',
  14.     cpvdimensions.dimensions_unit as 'Dimension Unit',
  15.     cpvweight.weight_number as 'Weight',
  16.     cpvweight.weight_unit as 'Weight Unit',
  17.     cpavfd.name as 'UOM'
  18. from commerce_product_variation_field_data cpvfd
  19. left join commerce_product_field_data cpfd
  20. on cpvfd.product_id = cpfd.product_id
  21. left join taxonomy_term_field_data c
  22. on cpfd.brand = c.tid and c.vid = 'brand'
  23. left join commerce_product_variation__dimensions cpvdimensions
  24. on cpvfd.variation_id = cpvdimensions.entity_id
  25. left join commerce_product_variation__weight cpvweight
  26. on cpvfd.variation_id = cpvweight.entity_id
  27. left join commerce_product_variation__attribute_uom cpvuom
  28. on cpvfd.variation_id = cpvuom.entity_id
  29. left join commerce_product_attribute_value_field_data cpavfd
  30. on cpvuom.attribute_uom_target_id = cpavfd.attribute_value_id
  31. left join (select
  32.         cpc.entity_id,
  33.         group_concat(DISTINCT ttfdcategory.name) as 'category'
  34.     from commerce_product__categories cpc
  35.     left join taxonomy_term_field_data ttfdcategory
  36.     on ttfdcategory.tid = cpc.categories_target_id and ttfdcategory.vid = 'product_category'
  37.     group by cpc.entity_id
  38. ) sub
  39. on cpvfd.product_id = sub.entity_id
  40. left join (select
  41.         ttp.entity_id,
  42.         ttfdcategory.name
  43.     from taxonomy_term__principal ttp
  44.     left join taxonomy_term_field_data ttfdcategory
  45.     on ttfdcategory.tid = ttp.principal_target_id and ttfdcategory.vid = 'principal'
  46. ) principal
  47. on cpfd.brand = principal.entity_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement