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 (
    2282, 2285, 2904, 2900, 2909, 2887, 2890, 
    2888, 2886, 8380, 7741, 10237, 10140, 
    10197, 10020, 10299, 8379, 10167, 10344, 
    10032, 10177, 10178, 10345, 8439, 10249, 
    10222, 10035, 10147, 10172, 10048, 
    10193, 10276, 10039, 10095, 10228, 
    10192, 10058, 8345, 10239, 10148, 10156, 
    10023, 10103, 10026, 10074, 10088, 
    10174, 10233, 10226, 10219, 10244, 
    10105, 10157, 10160, 10059, 9972, 10274, 
    10294, 10022, 10104, 10247, 10261, 
    9952, 10159, 10161, 10225, 10254, 10255, 
    10273, 9937, 9968, 10071, 10272, 9969, 
    10047, 10050, 10056, 10093, 10232, 
    10238
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00244

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "101.61"
    },
    "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": 102,
            "rows_produced_per_join": 102,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (2282,2285,2904,2900,2909,2887,2890,2888,2886,8380,7741,10237,10140,10197,10020,10299,8379,10167,10344,10032,10177,10178,10345,8439,10249,10222,10035,10147,10172,10048,10193,10276,10039,10095,10228,10192,10058,8345,10239,10148,10156,10023,10103,10026,10074,10088,10174,10233,10226,10219,10244,10105,10157,10160,10059,9972,10274,10294,10022,10104,10247,10261,9952,10159,10161,10225,10254,10255,10273,9937,9968,10071,10272,9969,10047,10050,10056,10093,10232,10238))",
            "cost_info": {
              "read_cost": "55.71",
              "eval_cost": "10.20",
              "prefix_cost": "65.91",
              "data_read_per_join": "1K"
            },
            "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": 5,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "25.50",
              "eval_cost": "0.51",
              "prefix_cost": "101.61",
              "data_read_per_join": "15K"
            },
            "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
2282 341,328,402,250,166,404M
2285 341,328,402,250,166,404M
2886 372,384,459M
2887 372,384,459M
2888 372,384,459M
2890 372,384,459M
2900 372,384,460M
2904 461,372,465M
2909 372,466,467M
7741 340M
8345 459M
8379 597M
8380 462M
8439 477M
9937 659M
9952 660M
9968 659M
9969 660M
9972 660M
10020 660M
10022 457M
10023 662M
10026 382M
10032 462M
10035 598M
10039 597M
10047 378M
10048 443M
10050 459M
10056 466M
10058 585M
10059 340M
10071 597M
10074 522M
10088 522M
10093 660M
10095 487,486M
10103 424M
10104 660M
10105 371M
10140 234,166,236M
10147 443M
10148 372M
10156 647M
10157 522M
10159 438,439M
10160 424M
10161 597M
10167 658M
10172 443M
10174 659M
10177 439M
10178 357M
10192 404,341M
10193 190,454M
10197 463M
10219 459M
10222 236M
10225 459M
10226 459M
10228 236M
10232 459M
10233 236M
10237 423M
10238 459M
10239 423M
10244 339M
10247 522M
10249 423M
10254 459M
10255 459M
10261 170M
10272 459M
10273 404M
10274 340M
10276 340M
10294 459M
10299 382M
10344 372M
10345 372M