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, 
  product_position_source.position AS position 
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') 
  LEFT JOIN cscart_products_categories AS product_position_source ON cscart_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 29 
WHERE 
  cscart_products_categories.product_id IN (
    10566, 10499, 10474, 10473, 10472, 10471, 
    31948, 10339, 10226, 10064, 10049, 
    8088, 6289, 4064, 3580, 3578, 3577, 
    6278, 6202, 3978
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00063

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 43 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
1 SIMPLE product_position_source eq_ref PRIMARY,pt PRIMARY 6 const,toolboxdigitalshop_dev.cscart_products_categories.product_id 1

Result

product_id category_ids position
3577 21,29,4M 0
3578 21,29,4M 0
3580 21,29,4M 0
3978 29,4M 0
4064 29,4M 0
6202 29,4M 0
6278 29,4M 0
6289 29,4M 0
8088 29,4M 0
10049 29,4M 0
10064 29,4M 0
10226 29,4M 0
10339 29,4M 0
10471 29,4M 0
10472 29,4M 0
10473 29,4M 0
10474 29,4M 0
10499 29,4M 0
10566 29,4M 0
31948 29,4M 0