SELECT
SQL_CALC_FOUND_ROWS products.product_id,
descr1.product as product,
companies.company as company_name,
products.product_type,
products.parent_product_id
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)
WHERE
1
AND cscart_categories.category_id IN (
166, 174, 175, 176, 177, 178, 179, 180,
181, 182, 199, 185, 186, 187, 188, 189,
190, 191, 194, 193, 195, 196, 197, 198,
200, 202, 234, 235, 236, 237, 238, 240,
254, 255, 263
)
AND companies.status IN ('A')
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.parent_product_id = 0
AND products.company_id IN(NULL)
AND products.product_type != 'D'
GROUP BY
products.product_id
ORDER BY
product asc,
products.product_id ASC
LIMIT
0, 12