Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.90 KB | None | 0 0
  1. SELECT
  2.     p.product_id,p.stock_status_id,
  3.     (SELECT
  4.             AVG(rating) AS total
  5.         FROM
  6.             oc_review r1
  7.         WHERE
  8.             r1.product_id = p.product_id
  9.                 AND r1.status = '1'
  10.         GROUP BY r1.product_id) AS rating,
  11.     (SELECT
  12.             price
  13.         FROM
  14.             oc_product_discount pd2
  15.         WHERE
  16.             pd2.product_id = p.product_id
  17.                 AND pd2.customer_group_id = '1'
  18.                 AND pd2.quantity = '1'
  19.                 AND ((pd2.date_start = '0000-00-00'
  20.                 OR pd2.date_start < NOW())
  21.                 AND (pd2.date_end = '0000-00-00'
  22.                 OR pd2.date_end > NOW()))
  23.         ORDER BY pd2.priority ASC , pd2.price ASC
  24.         LIMIT 1) AS discount,
  25.     (SELECT
  26.             price
  27.         FROM
  28.             oc_product_special ps
  29.         WHERE
  30.             ps.product_id = p.product_id
  31.                 AND ps.customer_group_id = '1'
  32.                 AND ((ps.date_start = '0000-00-00'
  33.                 OR ps.date_start < NOW())
  34.                 AND (ps.date_end = '0000-00-00'
  35.                 OR ps.date_end > NOW()))
  36.         ORDER BY ps.priority ASC , ps.price ASC
  37.         LIMIT 1) AS special
  38. FROM
  39.     oc_category_path cp
  40.         LEFT JOIN
  41.     oc_product_to_category p2c ON (cp.category_id = p2c.category_id)
  42.         LEFT JOIN
  43.     oc_product p ON (p2c.product_id = p.product_id)
  44.         LEFT JOIN
  45.     oc_manufacturer m ON (p.manufacturer_id = m.manufacturer_id)
  46.         LEFT JOIN
  47.     oc_product_description pd ON (p.product_id = pd.product_id)
  48.         LEFT JOIN
  49.     oc_product_to_store p2s ON (p.product_id = p2s.product_id)
  50. WHERE
  51.     pd.language_id = '2' AND p.status = '1'
  52.         AND p.quantity > '0'
  53.         AND p.date_available <= NOW()
  54.         AND p2s.store_id = '0'
  55.         AND cp.path_id = '1297'
  56. GROUP BY p.product_id
  57. ORDER BY p.date_added DESC , LCASE(pd.name) DESC
  58. LIMIT 0 , 20
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement