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 (
    124642, 124641, 124640, 124639, 124638, 
    124637, 124636, 124635, 124634, 124633, 
    124632, 124631, 124630, 124629, 124628, 
    124627, 124626, 124625, 124624, 124623, 
    124622, 124621, 124620, 124619
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00046

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 24 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
124619 22M
124620 22M
124621 22M
124622 22M
124623 22M
124624 22M
124625 22M
124626 22M
124627 22M
124628 22M
124629 22M
124630 22M
124631 22M
124632 22M
124633 22M
124634 22M
124635 22M
124636 22M
124637 22M
124638 22M
124639 22M
124640 22M
124641 22M
124642 22M