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, 
  product_position_source.position AS position 
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') 
  LEFT JOIN cscart_products_categories AS product_position_source ON cscart_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 2362 
WHERE 
  cscart_products_categories.product_id IN (
    38085, 64323, 64324, 64325, 64326, 64328, 
    64329, 64339, 64341, 64342, 64343, 
    64344, 64352, 66796, 64337, 64340, 
    64345, 64346, 64347, 64551, 64335, 
    64348, 64338, 38081
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00111

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "42.64"
    },
    "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": 29,
            "rows_produced_per_join": 29,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "3.33",
              "eval_cost": "2.90",
              "prefix_cost": "6.23",
              "data_read_per_join": "464"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`cscart_db`.`cscart_products_categories`.`product_id` in (38085,64323,64324,64325,64326,64328,64329,64339,64341,64342,64343,64344,64352,66796,64337,64340,64345,64346,64347,64551,64335,64348,64338,38081))"
          }
        },
        {
          "table": {
            "table_name": "product_position_source",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "pt",
              "idx_product_category_lookup",
              "idx_products_categories_composite"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id",
              "product_id"
            ],
            "key_length": "6",
            "ref": [
              "const",
              "cscart_db.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 29,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "23.37",
              "eval_cost": "2.90",
              "prefix_cost": "32.50",
              "data_read_per_join": "464"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "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": 23,
            "filtered": "81.96",
            "cost_info": {
              "read_cost": "7.25",
              "eval_cost": "2.38",
              "prefix_cost": "42.65",
              "data_read_per_join": "66K"
            },
            "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 position
38081 2362,2900M 2
38085 2362,2997M 2
64323 2362M 2
64324 2362M 2
64325 2362M 2
64326 2362M 2
64328 2362M 2
64329 2362M 2
64335 2362M 2
64337 2362M 2
64338 2362M 2
64339 2362M 2
64340 2362M 2
64341 2362M 2
64342 2362,2900M 2
64343 2362M 2
64344 2362M 2
64345 2362M 2
64346 2362M 2
64347 2362M 2
64348 2362M 2
64352 2362M 2
64551 2362,2900M 2
66796 2362,2735M 2