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 (
    42450, 42449, 42448, 42447, 42446, 42445, 
    42444, 42443, 42442, 42441, 42440, 
    42439, 42438, 42437, 42436, 42435, 
    42433, 42271, 42270, 42269
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00047

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 21 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
42269 4M
42270 4M
42271 18,13M
42433 1M
42435 3M
42436 1M
42437 1M
42438 3M
42439 1M
42440 1M
42441 1M
42442 1M
42443 1M
42444 4M
42445 1M
42446 1M
42447 1M
42448 1M
42449 3M
42450 4M