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 (
    908, 134, 955, 942, 941, 446, 953, 952, 
    951, 949, 948, 947, 946, 945, 944, 994, 
    996, 493, 985, 986, 988, 990, 991, 993, 
    1128, 1127, 1126, 1125, 1124, 1123, 
    1139, 1138, 1137, 1136, 1135, 1134, 
    1133, 1132, 1131, 1130, 1129, 827, 1142, 
    853, 1146, 1145, 1144, 1143, 856, 1322, 
    1262, 1317, 1318, 1319, 1320, 1321, 
    1256, 1395, 1396, 1397, 1399, 1406, 
    1407, 1408, 1409, 1410, 1411, 1412, 
    1273, 1425, 1427, 1428, 1429, 1431, 
    1266, 1442, 1447, 1263, 1458, 1284, 
    1475, 1476, 1477, 1274, 1483, 1484, 
    1485, 1486, 1487, 1540, 1541, 1542, 
    1543, 1538, 8496, 1517, 8498, 8497, 
    1532, 8502, 8501, 8499, 1528, 8505, 
    8503
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00493

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "251.86"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 282,
            "rows_produced_per_join": 282,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (908,134,955,942,941,446,953,952,951,949,948,947,946,945,944,994,996,493,985,986,988,990,991,993,1128,1127,1126,1125,1124,1123,1139,1138,1137,1136,1135,1134,1133,1132,1131,1130,1129,827,1142,853,1146,1145,1144,1143,856,1322,1262,1317,1318,1319,1320,1321,1256,1395,1396,1397,1399,1406,1407,1408,1409,1410,1411,1412,1273,1425,1427,1428,1429,1431,1266,1442,1447,1263,1458,1284,1475,1476,1477,1274,1483,1484,1485,1486,1487,1540,1541,1542,1543,1538,8496,1517,8498,8497,1532,8502,8501,8499,1528,8505,8503))",
            "cost_info": {
              "read_cost": "124.96",
              "eval_cost": "28.20",
              "prefix_cost": "153.16",
              "data_read_per_join": "4K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "softwarepirmam_hewadelivard_cscart_4.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 14,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "70.50",
              "eval_cost": "1.41",
              "prefix_cost": "251.86",
              "data_read_per_join": "44K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`storefront_id` in (0,1)) and ((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`))) and (`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
134 166,329,344M
446 234,166,235M
493 234,166,235M
827 166,322,323M
853 329,166,344M
856 329,166,344M
908 329,166,344M
941 234,166,235M
942 234,166,235M
944 166,234,235M
945 234,166,235M
946 166,234,235M
947 234,166,235M
948 234,166,235M
949 234,166,235M
951 234,166,235M
952 234,166,235M
953 234,166,235M
955 234,166,235M
985 166,234,235M
986 166,234,235M
988 234,166,235M
990 166,234,235M
991 234,166,235M
993 166,234,235M
994 234,166,235M
996 166,234,235M
1123 166,322,323M
1124 166,322,323M
1125 166,322,323M
1126 322,166,323M
1127 166,322,323M
1128 166,322,323M
1129 166,322,323M
1130 166,322,323M
1131 166,322,323M
1132 166,322,323M
1133 166,322,323M
1134 322,166,323M
1135 166,322,323M
1136 166,322,323M
1137 166,322,323M
1138 166,322,323M
1139 166,322,323M
1142 329,166,344M
1143 329,166,344M
1144 329,166,344M
1145 329,166,344M
1146 329,166,344M
1256 234,166,326M
1262 166,234,326M
1263 234,166,326M
1266 234,166,326M
1273 234,166,326M
1274 320,166,325M
1284 322,166,324M
1317 166,234,326M
1318 166,234,326M
1319 166,234,326M
1320 166,234,326M
1321 166,234,326M
1322 166,234,326M
1395 234,166,326M
1396 234,166,326M
1397 234,166,326M
1399 234,166,326M
1406 234,166,326M
1407 234,166,326M
1408 234,166,326M
1409 234,166,326M
1410 234,166,326M
1411 234,166,326M
1412 234,166,326M
1425 234,166,326M
1427 234,166,326M
1428 234,166,326M
1429 234,166,326M
1431 234,166,326M
1442 234,166,326M
1447 234,166,326M
1458 234,166,326M
1475 166,322,324M
1476 166,322,324M
1477 166,322,324M
1483 320,166,325M
1484 320,166,325M
1485 320,166,325M
1486 166,320,325M
1487 166,320,325M
1517 454,453,372,174,166,190M
1528 453,454,372,174,166,190M
1532 454,453,372,174,166,190M
1538 454,453,372,174,166,190M
1540 329,166,344M
1541 329,166,344M
1542 329,166,344M
1543 329,166,344M
8496 372,453,454,166,174,190M
8497 174,454,372,166,453,190M
8498 372,166,453,174,454,190M
8499 174,454,166,453,372,190M
8501 372,453,166,174,454,190M
8502 372,174,454,453,166,190M
8503 372,166,453,174,454,190M
8505 174,454,372,166,453,190M