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 (
    45239, 45238, 45237, 45236, 45235, 45234, 
    45233, 45232, 45231, 45230, 45229, 
    45228, 45227, 45226, 45225, 45224, 
    45223, 45222, 45221, 45220, 45219, 
    45218, 45217, 45216, 45215
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00052

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
45215 22M
45216 22M
45217 22M
45218 22M
45219 22M
45220 22M
45221 22M
45222 22M
45223 22M
45224 22M
45225 22M
45226 22M
45227 22M
45228 22M
45229 22M
45230 22M
45231 22M
45232 22M
45233 22M
45234 22M
45235 22M
45236 22M
45237 22M
45238 22M
45239 22M