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 (
    1206, 1384, 1389, 1393, 1404, 1403, 1402, 
    1401, 1398, 1400, 1394, 1399, 1397, 
    1396, 1395, 1340, 1337, 1338, 1339, 
    1347, 1390, 1342, 1341, 1016, 1381, 
    25, 1392, 1391, 1166, 1388, 1380, 1330, 
    1387, 1386, 1385, 1383, 1382, 1369, 
    1379, 1378, 1377, 1376, 1375, 1374, 
    1373, 1372, 1371, 1370
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00179

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 (1206,1384,1389,1393,1404,1403,1402,1401,1398,1400,1394,1399,1397,1396,1395,1340,1337,1338,1339,1347,1390,1342,1341,1016,1381,25,1392,1391,1166,1388,1380,1330,1387,1386,1385,1383,1382,1369,1379,1378,1377,1376,1375,1374,1373,1372,1371,1370)"
    },
    "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')"
    }
  }
}

Result

product_id category_ids
25 35M
1016 23M
1166 13M
1206 13M
1330 13M
1337 15M
1338 15M
1339 15M
1340 34M
1341 25M
1342 40M
1347 8M
1369 43M
1370 43M
1371 12M
1372 12M
1373 12M
1374 12M
1375 12M
1376 12M
1377 12M
1378 35M
1379 35M
1380 10M
1381 24M
1382 35M
1383 35M
1384 8M
1385 35M
1386 35M
1387 43M
1388 10M
1389 35M
1390 45M
1391 10M
1392 10M
1393 20M
1394 8M
1395 11M
1396 13M
1397 13M
1398 13M
1399 43M
1400 25M
1401 8M
1402 8M
1403 8M
1404 46M