SELECT 
  cscart_products_categories.product_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 
FROM 
  cscart_products_categories 
  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_categories.status IN ('A', 'H') 
WHERE 
  cscart_products_categories.product_id IN (
    125768, 125767, 125766, 125765, 125764, 
    125763, 125762, 125761, 125760, 125759, 
    125758, 125757, 125756, 125755, 125754, 
    125753, 125752, 125751, 125750, 125749, 
    125748, 125747, 125746, 125745, 125744
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00039

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 25 Using where; Using index
1 SIMPLE cscart_categories eq_ref PRIMARY,c_status,p_category_id PRIMARY 3 toolboxdigitalshop_dev.cscart_products_categories.category_id 1 Using where

Result

product_id category_ids
125744 22M
125745 22M
125746 22M
125747 22M
125748 22M
125749 22M
125750 22M
125751 22M
125752 22M
125753 22M
125754 22M
125755 22M
125756 22M
125757 22M
125758 22M
125759 22M
125760 22M
125761 22M
125762 22M
125763 22M
125764 22M
125765 22M
125766 22M
125767 22M
125768 22M