Guest User

Untitled

a guest
Jan 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. ```
  2. SELECT e.entity_id AS 'id',
  3. v1.value AS 'name',
  4. e.sku,
  5. d1.value AS 'price',
  6. t1.value AS 'short_description',
  7. t2.value AS 'description',
  8. v2.value AS 'image',
  9. v3.value AS 'thumbnail',
  10. mg.value AS 'media_gallery',
  11. cids.category_ids AS 'category_ids',
  12. cids.category_names AS 'category_names'
  13. FROM catalog_product_entity e
  14. LEFT JOIN catalog_product_entity_varchar v1 ON e.entity_id = v1.entity_id
  15. AND v1.store_id = 0
  16. AND v1.attribute_id =
  17. (SELECT attribute_id
  18. FROM eav_attribute
  19. WHERE attribute_code = 'name'
  20. AND entity_type_id =
  21. (SELECT entity_type_id
  22. FROM eav_entity_type
  23. WHERE entity_type_code = 'catalog_product'))
  24. LEFT JOIN catalog_product_entity_text t1 ON e.entity_id = t1.entity_id
  25. AND t1.store_id = 0
  26. AND t1.attribute_id =
  27. (SELECT attribute_id
  28. FROM eav_attribute
  29. WHERE attribute_code = 'short_description'
  30. AND entity_type_id =
  31. (SELECT entity_type_id
  32. FROM eav_entity_type
  33. WHERE entity_type_code = 'catalog_product'))
  34. LEFT JOIN catalog_product_entity_text t2 ON e.entity_id = t2.entity_id
  35. AND t2.store_id = 0
  36. AND t2.attribute_id =
  37. (SELECT attribute_id
  38. FROM eav_attribute
  39. WHERE attribute_code = 'description'
  40. AND entity_type_id =
  41. (SELECT entity_type_id
  42. FROM eav_entity_type
  43. WHERE entity_type_code = 'catalog_product'))
  44. LEFT JOIN catalog_product_entity_varchar v2 ON e.entity_id = v2.entity_id
  45. AND v2.store_id = 0
  46. AND v2.attribute_id =
  47. (SELECT attribute_id
  48. FROM eav_attribute
  49. WHERE attribute_code = 'image'
  50. AND entity_type_id =
  51. (SELECT entity_type_id
  52. FROM eav_entity_type
  53. WHERE entity_type_code = 'catalog_product'))
  54. LEFT JOIN catalog_product_entity_varchar v3 ON e.entity_id = v3.entity_id
  55. AND v3.store_id = 0
  56. AND v3.attribute_id =
  57. (SELECT attribute_id
  58. FROM eav_attribute
  59. WHERE attribute_code = 'thumbnail'
  60. AND entity_type_id =
  61. (SELECT entity_type_id
  62. FROM eav_entity_type
  63. WHERE entity_type_code = 'catalog_product'))
  64. LEFT JOIN catalog_product_entity_decimal d1 ON e.entity_id = d1.entity_id
  65. AND d1.store_id = 0
  66. AND d1.attribute_id =
  67. (SELECT attribute_id
  68. FROM eav_attribute
  69. WHERE attribute_code = 'price'
  70. AND entity_type_id =
  71. (SELECT entity_type_id
  72. FROM eav_entity_type
  73. WHERE entity_type_code = 'catalog_product'))
  74. LEFT JOIN
  75. (SELECT m1.entity_id,
  76. GROUP_CONCAT(m2.value) AS value
  77. FROM catalog_product_entity_media_gallery_value_to_entity m1
  78. INNER JOIN catalog_product_entity_media_gallery m2 ON m2.value_id = m1.value_id
  79. AND m2.attribute_id =
  80. (SELECT attribute_id
  81. FROM eav_attribute
  82. WHERE attribute_code = 'media_gallery'
  83. AND entity_type_id =
  84. (SELECT entity_type_id
  85. FROM eav_entity_type
  86. WHERE entity_type_code = 'catalog_product'))
  87. GROUP BY m1.entity_id) mg ON e.entity_id = mg.entity_id
  88. LEFT JOIN
  89. (SELECT product_id,
  90. GROUP_CONCAT(c.category_id SEPARATOR ',') AS category_ids,
  91. GROUP_CONCAT(cv.value SEPARATOR ',') AS category_names
  92. FROM catalog_category_product c
  93. INNER JOIN catalog_category_entity_varchar cv ON c.category_id = cv.entity_id
  94. AND cv.store_id = 0
  95. AND cv.attribute_id =
  96. (SELECT attribute_id
  97. FROM eav_attribute
  98. WHERE attribute_code = 'name'
  99. AND entity_type_id =
  100. (SELECT entity_type_id
  101. FROM eav_entity_type
  102. WHERE entity_type_code = 'catalog_category'))
  103. GROUP BY product_id) cids ON e.entity_id = cids.product_id ;
  104. ```
Add Comment
Please, Sign In to add comment