Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. SELECT
  2. `zoomall_products`.`id` AS `id`,
  3. `zoomall_products`.`is_gift` AS `is_gift`,
  4. `zoomall_products`.`flag` AS `flag`,
  5. `zoomall_products`.`created_at` AS `created_at`,
  6. COUNT(zoomall_products.id) OVER() AS `total_count`,
  7. (
  8. MATCH(
  9. t.description,
  10. t.categories_text,
  11. t.meta_keywords,
  12. t.title,
  13. t.short_title
  14. ) AGAINST('*аквариуми* *риби*' IN BOOLEAN MODE)
  15. ) AS `relevance`,
  16. `t`.`title` AS `title`,
  17. `t`.`short_title` AS `short_title`,
  18. `t`.`slug` AS `slug`,
  19. `b`.`id` AS `brand_id`,
  20. `b`.`title` AS `brand_title`,
  21. `b`.`slug` AS `brand_slug`,
  22. `im`.`filename` AS `image`,
  23. MAX(price_new) AS `max_price`,
  24. MIN(price_new) AS `min_price`,
  25. `i`.`price_old` AS `price_old`,
  26. COALESCE(AVG(rating), 0) AS `avg_rating`,
  27. `c`.`category_id` AS `categories`
  28. FROM
  29. `zoomall_products`
  30. INNER JOIN `zoomall_products_translations` AS `t` ON zoomall_products.id = t.product_id
  31. AND t.language = 'bg'
  32. LEFT JOIN `zoomall_brands` AS `b` ON zoomall_products.brand_id = b.id
  33. AND b.status = "active"
  34. LEFT JOIN `zoomall_products_images` AS `im` ON zoomall_products.id = im.product_id
  35. AND im.is_main = 1
  36. AND im.status = "active"
  37. INNER JOIN `zoomall_products_items` AS `i` ON zoomall_products.id = i.product_id
  38. and i.status = "active"
  39. LEFT JOIN `zoomall_products_reviews` AS `r` ON zoomall_products.id = r.product_id
  40. AND r.status = "active"
  41. INNER JOIN `zoomall_products_categories_links` AS `c` ON c.product_id = zoomall_products.id
  42. WHERE
  43. `zoomall_products`.`status` = 'active'
  44. AND (
  45. i.price_new > 0
  46. OR i.price_old > 0
  47. )
  48. AND MATCH(
  49. t.description,
  50. t.categories_text,
  51. t.meta_keywords,
  52. t.title,
  53. t.short_title
  54. ) AGAINST('*аквариуми* *риби*' IN BOOLEAN MODE)
  55. OR MATCH(
  56. t.description,
  57. t.categories_text,
  58. t.meta_keywords,
  59. t.title,
  60. t.short_title
  61. ) AGAINST('*akvariumi* *ribi*' IN BOOLEAN MODE)
  62. GROUP BY
  63. `zoomall_products`.`id`
  64. HAVING
  65. MIN(price_new) > 0
  66. AND COUNT(c.id) > 0
  67. ORDER BY
  68. `relevance` DESC
  69. LIMIT
  70. '20'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement