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 = 1 
WHERE 
  cscart_products_categories.product_id IN (
    31436, 31435, 31434, 31433, 31432, 31431, 
    31430, 31429, 31428, 31427, 31426, 
    31425, 31424, 31423, 14017, 13990, 
    13989, 13968, 13987, 13986, 13985, 
    13983, 13982, 13981, 13980, 13979, 
    13978, 13977, 13976, 13975, 13974, 
    13973, 13972, 13971, 13970, 13969, 
    16527, 13892, 13891, 13882
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00077

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 40 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
13882 1M 0
13891 1M 0
13892 1M 0
13968 1M 0
13969 1M 0
13970 1M 0
13971 1M 0
13972 1M 0
13973 1M 0
13974 1M 0
13975 1M 0
13976 1M 0
13977 1M 0
13978 1M 0
13979 1M 0
13980 1M 0
13981 1M 0
13982 1M 0
13983 1M 0
13985 1M 0
13986 1M 0
13987 1M 0
13989 1M 0
13990 1M 0
14017 1M 0
16527 1M 0
31423 1M 0
31424 1M 0
31425 1M 0
31426 1M 0
31427 1M 0
31428 1M 0
31429 1M 0
31430 1M 0
31431 1M 0
31432 1M 0
31433 1M 0
31434 1M 0
31435 1M 0
31436 1M 0