SELECT
SQL_CALC_FOUND_ROWS products.product_id,
descr1.product as product,
companies.company as company_name,
companies.ec_rfq_whatsapp_number,
companies.ec_rfq_bht,
companies.ec_rfq_phone_number,
companies.ec_rfq_bhf,
products.product_type,
products.parent_product_id,
cscart_ec_table_booking_system.booking_type as booking_type
FROM
cscart_products as products
LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id
AND descr1.lang_code = 'en'
LEFT JOIN cscart_product_prices as prices ON prices.product_id = products.product_id
AND prices.lower_limit = 1
LEFT JOIN cscart_companies AS companies ON companies.company_id = products.company_id
INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id
INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id
AND (
cscart_categories.usergroup_ids = ''
OR FIND_IN_SET(
0, cscart_categories.usergroup_ids
)
OR FIND_IN_SET(
1, cscart_categories.usergroup_ids
)
)
AND cscart_categories.status IN ('A', 'H')
AND cscart_categories.storefront_id IN (0, 1)
LEFT JOIN cscart_ec_table_booking_system ON cscart_ec_table_booking_system.product_id = products.product_id
LEFT JOIN cscart_product_popularity as popularity ON popularity.product_id = products.product_id
WHERE
1
AND cscart_categories.category_id IN (
6473,
10324,
6568,
6574,
6580,
6590,
6601,
6608,
6614,
6618,
6629,
6639,
6642,
6658,
6667,
6679,
6685,
6699,
6711,
6729,
6742,
6749,
6760,
6768,
6776,
6785,
6791,
6799,
6805,
6813,
6820,
6824,
6600,
6683,
6712,
6733,
6745,
6759,
6769,
6809,
6844,
6850,
6870,
6882,
6897,
6941,
6962,
6875,
6886,
6892,
6902,
6911,
6916,
6924,
6929,
6938,
6948,
6956,
6965,
6972,
6982,
6991,
7004,
7006,
7012,
7026,
7030,
7048,
7056,
7066,
7076,
7081,
7088,
7097,
7104,
7115,
7122,
7129,
7139,
7146,
7155,
7161,
7172,
7178,
7197,
7207,
7212,
6968,
7023,
7050,
7063,
7079,
7092,
7080,
7283,
7288,
7302,
7308,
7318,
7332,
7342,
7352,
7370,
7382,
7394,
7592,
7604,
7614,
7652,
7659,
7663,
7664,
7670,
7803,
7819,
7824,
7401,
7402,
7403,
7404,
7405,
7406,
7407,
7408,
7409,
7410,
7411,
7755,
7756,
7757,
7758,
7759,
7760,
7761,
7762,
7412,
7413,
7414,
7807,
7808,
7809,
7810,
7812,
7415,
7416,
7887,
7893,
7417,
7418,
7419,
7420,
7945,
7953,
7421,
7422,
7423,
7424,
7425,
7426,
7427,
7966,
7982,
7986,
7987,
7989,
7428,
7429,
7430,
7431,
7432,
7433,
7434,
7435,
8066,
8112,
8113,
8114,
8115,
8116,
8117,
8118,
8119,
8120,
8121,
8122,
8123,
8124,
8125,
8126,
8127,
8151,
8152,
8153,
8229,
8230,
8231,
8232,
8233,
8234,
8235,
8236,
8237,
8238,
8239,
8240,
8241,
8242,
8243,
8244,
8245,
8246,
8247,
8248,
8249,
7436,
8017,
8021,
8035,
8036,
8039,
8043,
8045,
8048,
8052,
7437,
7438,
7439,
7440,
7441,
7442,
8292,
8293,
8294,
8295,
8296,
8297,
8298,
8299,
8300,
7443,
7444,
7445,
7446,
7447,
7448,
7449,
7450,
7451,
7452,
7453,
7827,
7834,
7838,
7841,
7844,
7848,
7853,
7884,
7889,
7894,
7901,
7906,
7908,
7913,
7944,
7949,
7957,
7964,
7967,
7135,
7143,
7157,
7169,
7183,
7194,
7203,
7216,
7224,
7234,
7248,
7257,
7240,
7241,
7242,
7300,
7301,
7328,
7329,
7345,
7383,
7462,
7469,
7606,
7607,
7274,
7295,
7323,
7338,
7353,
7371,
7384,
8985,
9484,
9523,
7621,
7622,
7623,
8993,
8994,
8995,
8996,
8997,
8998,
8999,
9000,
9001,
9002,
9003,
9004,
9005,
7226,
7232,
7239,
7246,
7254,
7256,
7260,
7266,
7275,
7285,
7286,
7289,
7299,
7307,
7311,
7627,
7685,
7686,
7687,
7688,
7689,
7740,
7741,
7690,
7691,
7692,
7693,
7750,
7751,
7694,
7695,
7696,
7697,
7698,
7699,
7700,
7702,
7703,
7704,
7705,
7706,
7707,
7708,
7709,
7710,
7711,
7712,
7763,
7764,
7769,
7857,
7895,
7858,
7946,
7947,
7859,
7959,
7860,
7976,
7977,
7978,
7979,
7980,
7981,
7861,
7862,
7863,
7990,
7864,
7997,
7998,
7999,
7865,
7866,
7867,
7868,
8015,
7869,
8031,
8032,
8033,
8034,
7870,
7871,
8049,
8050,
8051,
7872,
7873,
7874,
8064,
8065,
7875,
8072,
7876,
8090,
8091,
8092,
8093,
8094,
7877,
8146,
8147,
7878,
8156,
8157,
7879,
7880,
7881,
8163,
7882,
7883,
8104,
8132,
7822,
7918,
7919,
7971,
7972,
7973,
7974,
7975,
7920,
7921,
8001,
8002,
8003,
8004,
8005,
8006,
8007,
7922,
7923,
7924,
7925,
7926,
7927,
7928,
7929,
7930,
7931,
8023,
8024,
8025,
8026,
8027,
8028,
8029,
8030,
7932,
7933,
8060,
8061,
8062,
8063,
7934,
7935,
7936,
7937,
7938,
7939,
7940,
7941,
8078,
8079,
8080,
8081,
8082,
8083,
8084,
8085,
7942
)
AND companies.status IN ('A')
AND products.company_id IN (
1,
25,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
108,
109,
110,
111,
122,
123,
124,
125,
126,
127,
128,
129,
130,
131,
132,
134,
135,
136,
137,
138,
139,
140,
141,
142,
143,
144,
145,
146,
148,
150,
152,
153,
154,
155,
156,
157,
158,
159,
160,
161,
162,
163,
164,
165,
166,
167,
168,
169,
170,
171,
172,
173,
174,
175,
176,
177,
178,
179,
180,
181,
182,
183,
184,
185,
186,
187,
188,
189,
190,
191,
192,
193,
194,
196,
197,
198,
199,
200,
202,
203,
204,
205,
206,
207,
208,
210,
211,
212,
213,
214,
215,
216,
217,
218,
219,
220,
221,
222,
223,
224,
225,
226,
227,
228,
229,
230,
231,
232,
233,
234,
235,
236,
237,
238,
239,
240,
241,
242,
243,
244,
245,
246,
247,
248,
249,
250,
251,
252,
253,
254,
255,
256,
257,
259,
260,
261,
262,
263,
264,
266,
268,
269,
271,
272,
273,
276,
277,
278,
279,
280,
281,
282,
284,
285,
286,
287,
288,
289,
290,
291,
292,
293,
294,
295,
296,
297,
298,
299,
300,
301,
302,
303,
304,
305,
306,
307,
308,
309,
310,
311,
312,
313,
314,
315,
316,
317,
318,
319,
321,
322,
323,
324,
325,
326,
327,
328,
329,
330,
331,
332,
333,
334,
335,
336,
337,
338,
339,
340,
341,
342,
343,
344,
345,
346,
347,
348,
349,
350,
351,
352,
353,
354,
355,
356,
357,
358,
359,
360,
361,
362,
363,
364,
365,
366,
367,
368,
369,
370,
371,
372,
373,
374,
377,
378,
379,
380,
381,
382,
383,
384,
385,
387,
388,
389,
391,
392,
393,
394,
395,
396,
397,
398,
400,
401,
402,
403,
404,
405,
406,
407,
408,
409,
410,
411,
414,
415,
416,
417,
418,
419,
420,
421,
422,
423,
424,
425,
426,
427,
428,
429,
430,
431,
432,
433,
434,
435,
436,
439,
440,
443,
445,
447,
448,
449,
450,
451,
452,
454,
455,
457,
458,
459,
460,
461,
462,
463,
465,
466,
467,
468,
469,
470,
471,
472,
473,
474,
476,
478,
479,
480,
481,
482,
483,
484,
485,
486,
487,
488,
489,
491,
492,
493,
494,
495,
496,
497,
498,
501,
503,
504,
505,
507,
508,
509,
510,
511,
512,
513,
514,
515,
516,
518,
519,
520,
522,
524,
525,
526,
527,
528,
531,
532,
533,
535,
537,
539,
540,
541,
542,
543,
545,
546,
547,
548,
549,
550,
551,
553,
554,
556,
557,
558,
559,
560,
561,
562,
563,
564,
566,
567,
568,
569,
575,
576,
577,
579,
580,
582,
583,
585,
586,
587,
588,
590,
591,
592,
593,
594,
595,
596,
597,
598,
600,
602,
603,
604,
606,
607,
609,
610,
611,
613,
618,
620,
621,
622,
623,
624,
625,
626,
627,
628,
629,
630,
631,
632,
633,
634,
635,
636,
637,
639,
641,
642,
643,
644,
646,
647,
649,
655,
660,
661,
662,
663,
665,
668,
669,
670,
671,
672,
673,
674,
675,
676,
678,
679,
680,
681,
682,
685,
686,
687,
688,
689,
690,
691,
692,
693,
694,
695,
696,
697,
707,
719,
0
)
AND products.company_id = 707
AND (
products.usergroup_ids = ''
OR FIND_IN_SET(0, products.usergroup_ids)
OR FIND_IN_SET(1, products.usergroup_ids)
)
AND products.status IN ('A')
AND prices.usergroup_id IN (0, 0, 1)
AND products.company_id = 707
AND products.parent_product_id = 0
GROUP BY
products.product_id
ORDER BY
popularity.total desc,
products.product_id ASC
LIMIT
0, 100