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.00564

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