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.status IN ('A', 'H') 
WHERE 
  cscart_products_categories.product_id IN (
    29989, 69055, 69077, 26800, 69059, 69097, 
    69076, 29990, 69060, 69062, 69066, 
    69064, 26799, 28654, 69056, 69074, 
    69063, 69091, 26051, 19109, 21338, 
    69065, 69069, 69083
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00165

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "14.76"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt",
              "idx_product_category_lookup",
              "idx_products_categories_composite"
            ],
            "key": "idx_products_categories_composite",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 26,
            "rows_produced_per_join": 26,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "3.06",
              "eval_cost": "2.60",
              "prefix_cost": "5.66",
              "data_read_per_join": "416"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`cscart_db`.`cscart_products_categories`.`product_id` in (29989,69055,69077,26800,69059,69097,69076,29990,69060,69062,69066,69064,26799,28654,69056,69074,69063,69091,26051,19109,21338,69065,69069,69083))"
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "p_category_id",
              "idx_categories_storefront_status",
              "idx_categories_usergroup_status",
              "idx_categories_status_id_path"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "cscart_db.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 21,
            "filtered": "81.96",
            "cost_info": {
              "read_cost": "6.50",
              "eval_cost": "2.13",
              "prefix_cost": "14.76",
              "data_read_per_join": "59K"
            },
            "used_columns": [
              "category_id",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`cscart_db`.`cscart_categories`.`storefront_id` in (0,1)) and (`cscart_db`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
19109 2828M
21338 2828M
26051 1952,2825M
26799 2819M
26800 2814M
28654 2828M
29989 2708,2813M
29990 2819M
69055 2693M
69056 2828M
69059 2814M
69060 2814M
69062 2813M
69063 2819M
69064 2813M
69065 2813M
69066 2822M
69069 2814M
69074 2699M
69076 2819M
69077 2828M
69083 2699M
69091 2828M
69097 2825M