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 (
    1371, 1493, 340, 293, 379, 1159, 311, 
    406, 304, 1058, 1188, 1293, 1116, 1368, 
    1020, 1136, 2500, 2513, 1135, 1252, 
    286, 118, 932, 1138, 1144, 1160, 1200, 
    354, 989, 2503, 1247, 1145
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00438

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": 33,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (1371,1493,340,293,379,1159,311,406,304,1058,1188,1293,1116,1368,1020,1136,2500,2513,1135,1252,286,118,932,1138,1144,1160,1200,354,989,2503,1247,1145)"
    },
    "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": ["dev.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')"
    }
  }
}

Result

product_id category_ids
118 62M
286 70M
293 45M
304 86M
311 89M
340 35M
354 35M
379 35M
406 35M
932 136M
989 80M
1020 80M
1058 114M
1116 114M
1135 70M
1136 70M
1138 70M
1144 70M
1145 70M
1159 75M
1160 75M
1188 72M
1200 71M
1247 40M
1252 49M
1293 76M
1368 114M
1371 114M
1493 44M
2500 58M
2503 59M
2513 44M