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 (
    1230, 1229, 1228, 1227, 1226, 1225, 1224, 
    1223, 1222, 1221, 1220, 1219, 1218, 
    1217, 1216, 1215, 1170, 1171, 1177, 
    1175, 1168, 1183, 1184, 1174, 1187, 
    67, 1191, 1176, 1167, 1169, 1194, 1179, 
    1180, 1181, 1197, 1182, 1201, 1202, 
    1198, 1178, 603, 1185, 1209, 1186, 1210, 
    1211, 1203, 1212, 1213, 1188, 1190, 
    1193, 1207, 1208, 1195, 1196, 1199, 
    1205, 1173, 1200, 1172, 15, 16, 17, 18, 
    19, 20, 21, 22, 26, 27, 28, 29, 30, 31, 
    32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 
    42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 
    52
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00284

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": 96,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (1230,1229,1228,1227,1226,1225,1224,1223,1222,1221,1220,1219,1218,1217,1216,1215,1170,1171,1177,1175,1168,1183,1184,1174,1187,67,1191,1176,1167,1169,1194,1179,1180,1181,1197,1182,1201,1202,1198,1178,603,1185,1209,1186,1210,1211,1203,1212,1213,1188,1190,1193,1207,1208,1195,1196,1199,1205,1173,1200,1172,15,16,17,18,19,20,21,22,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52)"
    },
    "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
15 6M
16 6M
17 8M
18 8M
19 8M
20 6M
21 9M
22 10M
26 9M
27 9M
28 9M
29 12M
30 8M
31 8M
32 9M
33 13M
34 10M
35 10M
36 10M
37 14M
38 10M
39 15M
40 16M
41 17M
42 16M
43 16M
44 16M
45 16M
46 18M
47 16M
48 16M
49 19M
50 9M
51 18M
52 6M
67 13M
603 10M
1167 25M
1168 8M
1169 12M
1170 34M
1171 15M
1172 17M
1173 6M
1174 15M
1175 10M
1176 24M
1177 25M
1178 25M
1179 8M
1180 8M
1181 30M
1182 24M
1183 8M
1184 34M
1185 27M
1186 35M
1187 35M
1188 35M
1190 35M
1191 24M
1193 24M
1194 35M
1195 25M
1196 17M
1197 13M
1198 8M
1199 8M
1200 8M
1201 24M
1202 24M
1203 35M
1205 8M
1207 35M
1208 25M
1209 35M
1210 35M
1211 8M
1212 8M
1213 6M
1215 15M
1216 15M
1217 15M
1218 25M
1219 24M
1220 24M
1221 24M
1222 10M
1223 6M
1224 24M
1225 16M
1226 39M
1227 24M
1228 9M
1229 30M
1230 24M