Advertisement
Guest User

Untitled

a guest
May 26th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.27 KB | None | 0 0
  1. SELECT pe.entity_id as 'product_id', pe.category_mid, pe.category_mid_id, pe.type_id,
  2. name.value as 'product_name', img_url.value as 'image_src', url0.value as product_url_store_0, url1.value as product_url_store_1,
  3. GREATEST(IFNULL(rating.numericScore,0), IFNULL(review.reviews_count,0)) as 'rating_count', review.rating_summary,
  4. if(sp.value = 0, 0, concat(format(sp.value, 0,'vi_VN'),'đ')) as 'display_final_price',
  5. if(p.value = 0, 0, concat(format(p.value, 0, 'vi_VN'), 'đ')) as 'display_price',
  6. if(sp.value = 0, 0, ROUND(((p.value - sp.value)/p.value)*100)) as 'discount',
  7. if(bd.final_price = 0, 0, concat(format(bd.final_price, 0, 'vi_VN'), 'đ')) as 'bundle_display_final_price',
  8. if(bd.price = 0, 0, concat(format(bd.price, 0, 'vi_VN'), 'đ')) as 'bundle_display_price',
  9. if(bd.final_price = 0, 0, ROUND(((bd.price - bd.final_price) / bd.price) * 100)) as 'bundle_discount'
  10. FROM fhs_personalize_products pp
  11. JOIN fhs_catalog_product_entity pe ON pp.related_pid = pe.entity_id
  12. LEFT JOIN fhs_catalog_product_entity_varchar name ON name.entity_id = pe.entity_id AND name.attribute_id = 71
  13. LEFT JOIN fhs_catalog_product_entity_varchar img_url ON pe.entity_id=img_url.entity_id AND img_url.attribute_id=85
  14. LEFT JOIN fhs_product_rating rating ON rating.sku = pe.sku
  15. LEFT JOIN fhs_review_entity_summary review ON review.entity_pk_value = pe.entity_id AND review.store_id=1
  16. LEFT JOIN fhs_catalog_product_entity_decimal p ON p.entity_id = pe.entity_id AND p.attribute_id = 75
  17. LEFT JOIN fhs_catalog_product_entity_decimal sp ON sp.entity_id = pe.entity_id AND sp.attribute_id = 76 AND sp.store_id = 0
  18. LEFT JOIN fhs_catalog_product_entity_varchar url0 ON pe.entity_id = url0.entity_id AND url0.attribute_id = 98 AND url0.store_id=0
  19. LEFT JOIN fhs_catalog_product_entity_varchar url1 ON pe.entity_id = url1.entity_id AND url1.attribute_id = 98 AND url1.store_id=1
  20. LEFT JOIN fhs_catalog_product_index_price_store bd ON pe.entity_id = bd.entity_id AND bd.customer_group_id = 0 AND bd.store_id = 1
  21. INNER JOIN fhs_catalog_product_entity_int AS ei ON ei.entity_id = pe.entity_id AND ei.attribute_id = '102' AND ei.store_id = 0 AND ei.value = 4
  22. INNER JOIN fhs_catalog_product_entity_int AS ei2 ON ei2.entity_id = pe.entity_id AND ei2.attribute_id = '96' AND ei2.store_id = 0 AND ei2.value = 1
  23. GROUP BY pe.entity_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement