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

Query time 0.00932

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "186.74"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "21.96"
      },
      "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.87",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (421,443,1971,418,1959,1930,1960,436,438,437,1961,1931,381,1529,2001,1465,1962,1933,1935,1958,428,406,439,390,1969,1929,398,1964,434,383,1927,435,419,403,324,1965,440,1966,431,1973))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "4.39",
              "prefix_cost": "138.42",
              "data_read_per_join": "351"
            },
            "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.96",
              "eval_cost": "4.39",
              "prefix_cost": "164.78",
              "data_read_per_join": "351"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

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