SELECT
cscart_products.product_id,
cscart_products.company_id,
GROUP_CONCAT(
IF(
cscart_products_categories.link_type = 'M',
CONCAT(
cscart_products_categories.category_id,
'M'
),
cscart_products_categories.category_id
)
) as category_ids,
cscart_products.product_code,
cscart_products.weight,
cscart_products.tracking,
cscart_product_descriptions.product,
cscart_product_descriptions.short_description,
cscart_products.is_edp,
cscart_products.edp_shipping,
cscart_products.shipping_freight,
cscart_products.free_shipping,
cscart_products.zero_price_action,
cscart_products.tax_ids,
cscart_products.qty_step,
cscart_products.list_qty_count,
cscart_products.max_qty,
cscart_products.min_qty,
cscart_products.amount as in_stock,
cscart_products.shipping_params,
cscart_companies.status as company_status,
cscart_products.out_of_stock_actions,
cscart_products.updated_timestamp,
cscart_companies.company as company_name,
IF(
shared_descr.product_id IS NOT NULL,
shared_descr.product, cscart_product_descriptions.product
) as product,
IF(
shared_descr.product_id IS NOT NULL,
shared_descr.short_description,
cscart_product_descriptions.short_description
) as short_description
FROM
cscart_products
LEFT JOIN cscart_product_descriptions ON cscart_product_descriptions.product_id = cscart_products.product_id
AND cscart_product_descriptions.lang_code = 'en'
INNER JOIN cscart_products_categories ON cscart_products_categories.product_id = cscart_products.product_id
INNER JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id
AND cscart_categories.storefront_id IN (0, 1)
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_products.usergroup_ids = ''
OR FIND_IN_SET(
0, cscart_products.usergroup_ids
)
OR FIND_IN_SET(
1, cscart_products.usergroup_ids
)
)
AND cscart_categories.status IN ('A', 'H')
AND cscart_products.status IN ('A', 'H')
LEFT JOIN cscart_companies ON cscart_companies.company_id = cscart_products.company_id
LEFT JOIN cscart_ult_product_descriptions shared_descr ON shared_descr.product_id = cscart_products.product_id
AND shared_descr.company_id = 1
AND shared_descr.lang_code = 'en'
WHERE
cscart_products.product_id = 298
GROUP BY
cscart_products.product_id