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 (
    125018, 125017, 125016, 125015, 125014, 
    125013, 125012, 125011, 125010, 125009, 
    125008, 125007, 125006, 125005, 125004, 
    125003, 125002, 125001, 125000, 124999, 
    124998, 124997, 124996
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00042

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 35 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
124996 4M
124997 4M
124998 4M
124999 29,4M
125000 29,4M
125001 4M
125002 4M
125003 29,4M
125004 29,4M
125005 29,4M
125006 4M
125007 29,4M
125008 29,4M
125009 29,4M
125010 29,4M
125011 29,4M
125012 3M
125013 29,4M
125014 4M
125015 29,4M
125016 1M
125017 4M
125018 1M