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.company_id = 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') 
  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 = 362 
WHERE 
  cscart_products_categories.product_id IN (
    1969, 398, 1964, 434, 383, 1927, 435, 
    419, 403, 324, 1965, 440, 1966, 431, 
    1928, 1973, 1968, 1963, 327, 1934, 2000, 
    2001, 385, 405
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00588

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "166.86"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "12.93"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 115,
            "rows_produced_per_join": 2,
            "filtered": "2.00",
            "cost_info": {
              "read_cost": "27.56",
              "eval_cost": "0.46",
              "prefix_cost": "28.02",
              "data_read_per_join": "6K"
            },
            "used_columns": [
              "category_id",
              "company_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`eshopuga_upgr_4122`.`cscart_categories`.`company_id` = 1) and ((`eshopuga_upgr_4122`.`cscart_categories`.`usergroup_ids` = '') or find_in_set(0,`eshopuga_upgr_4122`.`cscart_categories`.`usergroup_ids`) or find_in_set(1,`eshopuga_upgr_4122`.`cscart_categories`.`usergroup_ids`)) and (`eshopuga_upgr_4122`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "eshopuga_upgr_4122.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 40,
            "rows_produced_per_join": 12,
            "filtered": "14.05",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (1969,398,1964,434,383,1927,435,419,403,324,1965,440,1966,431,1928,1973,1968,1963,327,1934,2000,2001,385,405))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "2.59",
              "prefix_cost": "138.42",
              "data_read_per_join": "206"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "product_position_source",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id",
              "product_id"
            ],
            "key_length": "6",
            "ref": [
              "const",
              "eshopuga_upgr_4122.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 12,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "12.93",
              "eval_cost": "2.59",
              "prefix_cost": "153.94",
              "data_read_per_join": "206"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
324 354,394,358,361,350,356,390,391,392,368,388,338M,396,363,340,360,352,351,362,359,355,395,393,357,353,349 0
327 385,353,349M,377,354,384,358,381,361,350,356,382,370,363,374,360,352,351,371,386,372,362,359,355,375,373,369,379,383,380,378,357,376 0
383 357,342,376,385,345,353,349,377,354,343,384,337M,358,368,381,361,350,338,356,344,370,340,363,374,347,360,352,351,339,371,386,372,362,359,355,375,373,341,378 0
385 372,362,359,355,375,373,341,378,357,394,342,376,390,391,345,392,353,349,377,388,396,354,343,337M,358,368,361,350,338,356,344,370,395,340,393,363,374,347,360,369,352,351,339,371 0
398 347,360,352,351,339,362,359,355,341,357,394,342,390,391,345,392,353,349,388,396,354,343,337M,358,368,361,350,338,356,389,344,395,340,393,363 0
403 395,393,363,360,362,359M,394,392,388,368,361 0
405 344,368,361,340,369,371,372,375,395,347,373,393,363,352,351,339,378,355,360,341,376,357,362,342,359,377,390,391,394,345,353,349,396,354,343,392,337M,358,370,388,350,338,356,374 0
419 337M,358,388,350,338,356,344,368,361,340,395,393,363,352,351,339,355,360,341,357,362,342,359,390,391,394,345,353,349,396,354,343,389,392 0
431 353,349,396,354,343,392,337M,358,388,350,338,356,344,368,361,395,393,363,352,351,339,355,360,341,357,362,342,359,390,391,394,345 0
434 345,353,349,354,343,385,337M,358,350,347,340,338,356,382,344,368,361,384,381,363,352,351,339,355,360,341,379,383,357,380,386,362,342,359 0
435 360,379,383,390,380,386,391,394,362,359,396,392,349M,388,385,382,368,395,361,384,393,381,363,352,351 0
440 363,370,374,360,369,390,371,391,394,362,359M,372,375,373,396,392,388,376,377,368,395,361,393 0
1927 361M,351,363,370,379,345,374,353,369,390,391,362,359,378,349,337,358,350,340,338,377,339 0
1928 339,361M,370,379,345,374,369,390,391,362,359,378,349,350,338,381,395 0
1934 377,352,381,342,395,339,361M,360,363,354,394,372,370,356,373,379,396,345,374,344,337,358,340,369,390,391,362,359,349,350,338,384,355 0
1963 350,338,377,352,381,339,361M,360,363,370,388,379,378,337,340,369,362,359,349 0
1964 340,369,362,359,349,338,377,381,339,361M,360,363,370,379,378,337,368 0
1965 379,337,368,340,369,362,359,349,338,352,377,381,339,361M,360,363,370 0
1966 370,379,337,368,340,369,362,359,349,338,352,377,381,339,361M,360,363 0
1968 361M,360,363,350,370,379,337,340,369,362,359,349,338,352,381,339 0
1969 339,361M,360,363,350,370,368,379,337,340,369,362,359,349,338,352,381 0
1973 381,339,361M,360,363,370,368,379,337,340,377,369,362,359,349,338,352 0
2000 362,349,338,363,396M,390,391,369 0
2001 390,391,369,362,349,338,363,396M 0