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 (
    421, 443, 1971, 1959, 1930, 1960, 321, 
    436, 438, 437, 1961, 1931, 381, 1529, 
    2001, 1465, 1932, 1962, 1933, 1935, 
    1958, 428, 406, 439, 390, 1969, 398, 
    1964, 434, 383, 1927, 435, 419, 403, 
    324, 1965, 440, 1966, 431, 1928
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00976

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "185.35"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "21.33"
      },
      "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": 21,
            "filtered": "23.19",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (421,443,1971,1959,1930,1960,321,436,438,437,1961,1931,381,1529,2001,1465,1932,1962,1933,1935,1958,428,406,439,390,1969,398,1964,434,383,1927,435,419,403,324,1965,440,1966,431,1928))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "4.27",
              "prefix_cost": "138.42",
              "data_read_per_join": "341"
            },
            "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": 21,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "21.33",
              "eval_cost": "4.27",
              "prefix_cost": "164.02",
              "data_read_per_join": "341"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
321 359,349M,362 0
324 338M,390,362,361,354,395,363,357,359,368,391,358,392,393,355,349,388,352,394,360,396,350,351,353,340,356 0
381 337M,351,344,376,385,353,340,382,356,338,362,339,361,354,363,341,357,386,359,372,380,373,358,381,345,355,375,347,342,384,349,343,378,374,352,371,379,360,370,383,350 0
383 360,370,350,337M,351,344,376,385,353,340,356,338,362,339,377,361,354,368,363,341,357,386,359,372,373,358,381,345,355,375,347,342,384,349,343,378,374,352,371 0
390 349,343,352,390,360,350,395,337M,351,344,353,340,356,391,338,362,339,392,361,354,368,393,363,341,357,359,388,394,358,345,355,396,347,342 0
398 345,355,396,347,342,349,343,352,390,360,350,395,337M,351,344,353,340,356,391,338,362,389,339,392,361,354,368,393,363,341,357,359,388,394,358 0
403 388,394,360,395,362,392,361,368,393,363,359M 0
406 362,392,361,368,393,363,359,358,345,388,355,394,396,347,342,349,343,352,390,350,337M,351,360,344,353,340,356,391,395,338,339,354,341,357 0
419 339,354,341,357,362,392,361,368,393,363,359,358,345,388,355,394,396,342,349,343,352,390,350,337M,351,360,344,389,353,340,356,391,395,338 0
421 344,353,340,356,391,395,338,339,354,341,357,362,392,361,368,393,363,359,358,345,388,355,394,396,342,349,343,352,390,350,337M,351,360 0
428 350,337M,351,360,344,353,340,356,391,395,338,339,354,341,357,347,362,392,361,368,393,363,359,358,345,388,355,394,396,342,349,343,352,390 0
431 352,390,350,337M,351,360,344,353,356,391,395,338,339,354,341,357,362,392,361,368,393,363,359,358,345,388,355,394,396,342,349,343 0
434 355,383,342,349,343,352,382,340,350,385,337M,351,360,344,353,356,338,380,347,386,339,354,341,357,362,381,361,368,363,359,358,345,379,384 0
435 361,368,363,394,396,359,379,384,383,349M,390,352,382,385,391,395,351,360,380,386,392,393,362,381,388 0
436 362,361,368,363,359M,360 0
437 362,361,368,363,359M,360 0
438 360,362,361,368,363,359M 0
439 378,374,358,345,371,381,355,370,342,360,343,379,384,383,376,349,352,340,350,362,337M,377,382,361,344,368,363,353,359,372,385,338,351,373,339,354,369,341,357,375,386 0
440 369,393,375,388,374,394,396,371,370,360,390,376,391,395,362,377,361,368,363,359M,372,373,392 0
443 359M,360,362,361,368,363 0
1465 354,372,362,341,357,373,361M,368,386,363,392,359,378,369,393,358,345,375,381,388,355,374,394,396,342,343,371,379,384,370,383,349,390,352,340,350,360,356,376,337,382,347,344,353,385,391,395,338,377,380,351,339 0
1529 385,391,395,338,377,380,351,339,354,372,362,341,357,373,361,368,386,363,392,359,378,369,393,358,345,375,381,388,355,374,394,396,342,343,371,379,384,370,349M,390,352,340,350,360,356,376,337,347,344,353 0
1927 350,337,353,391,338,377,351,339,362,361M,363,359,378,369,358,345,374,379,370,349,390,340 0
1928 349,390,350,395,391,338,339,362,361M,381,359,378,369,345,374,379,370 0
1930 356,376,379,340,337,349,390,353,350,354,395,341,377,351,391,338,375,363,339,388,362,355,361M,381,359,369,345,352 0
1931 360,345,376,385,380,379,340,372,337,349,390,353,350,395,391,338,396,342,371,363,339,388,362,361M,381,359,369,374 0
1932 381,352,359,369,345,379,349,377,390,350,394,384,378,391,338,339,388,362M 0
1933 361M,339,388,362,374,370,360,381,352,359,369,376,345,386,340,372,341,337,379,349,390,350,355,394,396,363,391,338 0
1935 363,344,391,338,361M,339,388,362,374,360,380,381,352,359,369,376,393,345,340,372,395,337,379,349,390,342,384,350,394 0
1958 363,338,370,361M,339,388,368,362,360,381,352,359,369,377,340,337,379,349 0
1959 379,350,349,363,338,370,361M,339,368,362,360,381,352,359,369,377,340,337 0
1960 340,337,379,349,363,338,370,361M,339,368,362,360,381,352,359,369,378,377 0
1961 381,359,369,378,377,340,350,337,379,349,363,338,370,361M,339,368,362,360 0
1962 339,352,362,360,381,359,369,377,340,350,337,379,388,349,363,338,370,361M,390 0
1964 363,368,338,370,361M,339,362,360,378,381,359,369,377,340,337,379,349 0
1965 363,352,368,338,370,361M,339,362,360,381,359,369,377,340,337,379,349 0
1966 349,363,352,368,338,370,361M,339,362,360,381,359,369,377,340,337,379 0
1969 340,337,379,349,363,352,368,338,370,350,361M,339,362,360,381,359,369 0
1971 340,337,379,349,363,352,368,338,370,350,361M,339,362,360,377,381,359,369 0
2001 362,369,390,391,349,363,338,396M 0