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 (
    10451, 10537, 10540, 10360, 10367, 10374, 
    10377, 10382, 10386, 10389, 10409, 
    10421, 10423, 10456, 10465, 10469, 
    10487, 10538, 10543, 10566, 10569, 
    10366, 10375, 10380, 10385, 10391, 
    10408, 10410, 10417, 10419, 10422, 
    10424, 10431, 10458, 10479, 10484, 
    10539, 10541, 10544, 10433
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00146

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "46.81"
    },
    "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": 46,
            "rows_produced_per_join": 46,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (10451,10537,10540,10360,10367,10374,10377,10382,10386,10389,10409,10421,10423,10456,10465,10469,10487,10538,10543,10566,10569,10366,10375,10380,10385,10391,10408,10410,10417,10419,10422,10424,10431,10458,10479,10484,10539,10541,10544,10433))",
            "cost_info": {
              "read_cost": "26.11",
              "eval_cost": "4.60",
              "prefix_cost": "30.71",
              "data_read_per_join": "736"
            },
            "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": 2,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "11.50",
              "eval_cost": "0.23",
              "prefix_cost": "46.81",
              "data_read_per_join": "7K"
            },
            "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
10360 573M
10366 372M
10367 372M
10374 556M
10375 574M
10377 556M
10380 575M
10382 575M
10385 372,587M
10386 372,587M
10389 372,587M
10391 587M
10408 574M
10409 575M
10410 575M
10417 466M
10419 466M
10421 574M
10422 574M
10423 574M
10424 574M
10431 578M
10433 578M
10451 566,597M
10456 597,566M
10458 597,566M
10465 566,597M
10469 572M
10479 573M
10484 574M
10487 574M
10537 467M
10538 466M
10539 587M
10540 372M
10541 572M
10543 579M
10544 579M
10566 466M
10569 453,174M