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 (
    125590, 125589, 125588, 125587, 125586, 
    125585, 125584, 125583, 125582, 125581, 
    125580, 125579, 125578, 125577, 125576, 
    125575, 125574, 125573, 125572, 125571, 
    125570, 125569, 125568, 125567, 125566, 
    125565, 125564, 125563, 125562, 125561, 
    125560, 125559, 125558, 125557
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00051

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 36 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
125557 4M
125558 4M
125559 4M
125560 4M
125561 4M
125562 4M
125563 4M
125564 4M
125565 4M
125566 88,4M
125567 4M
125568 88,4M
125569 4M
125570 4M
125571 4M
125572 4M
125573 4M
125574 4M
125575 4M
125576 4M
125577 4M
125578 4M
125579 4M
125580 4M
125581 4M
125582 4M
125583 4M
125584 4M
125585 4M
125586 4M
125587 4M
125588 4M
125589 4M
125590 4M