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 = 9 
WHERE 
  cscart_products_categories.product_id IN (
    394, 402, 129, 126, 147, 152, 1041, 818, 
    816, 66, 27, 28, 1159, 1160, 1158, 1164, 
    1165, 119, 120, 121, 731, 90, 82, 829, 
    1007, 1006, 1003, 1004, 1005, 108, 109, 
    110, 1318, 92, 80, 55, 140, 134, 350, 
    21, 91, 136, 135, 1228, 933, 1239, 70, 
    123
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00079

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "cscart_products_categories",
      "access_type": "range",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "pt",
      "key_length": "3",
      "used_key_parts": ["product_id"],
      "rows": 49,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (394,402,129,126,147,152,1041,818,816,66,27,28,1159,1160,1158,1164,1165,119,120,121,731,90,82,829,1007,1006,1003,1004,1005,108,109,110,1318,92,80,55,140,134,350,21,91,136,135,1228,933,1239,70,123)"
    },
    "table": {
      "table_name": "cscart_categories",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
      "key": "PRIMARY",
      "key_length": "3",
      "used_key_parts": ["category_id"],
      "ref": ["bacpvdev_db.cscart_products_categories.category_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "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')"
    },
    "table": {
      "table_name": "product_position_source",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "PRIMARY",
      "key_length": "6",
      "used_key_parts": ["category_id", "product_id"],
      "ref": ["const", "bacpvdev_db.cscart_products_categories.product_id"],
      "rows": 1,
      "filtered": 100
    }
  }
}

Result

product_id category_ids position
21 9M 0
27 9M 0
28 9M 0
55 9M 0
66 9M 0
70 9M 0
80 9M 0
82 9M 0
90 9M 0
91 9M 0
92 9M 0
108 9M 0
109 9M 0
110 9M 0
119 9M 0
120 9M 0
121 9M 0
123 9M 0
126 9M 0
129 9M 0
134 9M 0
135 9M 0
136 9M 0
140 9M 0
147 9M 0
152 9M 0
350 9M 0
394 9M 0
402 9M 0
731 9M 0
816 9M 0
818 9M 0
829 9M 0
933 9M 0
1003 9M 0
1004 9M 0
1005 9M 0
1006 9M 0
1007 9M 0
1041 9M 0
1158 9M 0
1159 9M 0
1160 9M 0
1164 9M 0
1165 9M 0
1228 9M 0
1239 9M 0
1318 9M 0