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 = 369 
WHERE 
  cscart_products_categories.product_id IN (
    427, 408, 1971, 382, 418, 1959, 1930, 
    1960, 1961, 1931, 1529, 1465, 1932, 
    1962, 1933, 1935, 1958, 329, 439, 1969, 
    393, 394, 1929, 396, 1964, 1927, 1965, 
    440, 1966, 1928, 1973, 1968, 1963, 327, 
    1934, 2000, 2001, 385, 405, 413, 1970, 
    1937, 414, 389, 1972, 1974, 442, 1936, 
    326, 441, 322, 1957
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.02010

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "204.80"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "30.17"
      },
      "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": 30,
            "filtered": "32.80",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (427,408,1971,382,418,1959,1930,1960,1961,1931,1529,1465,1932,1962,1933,1935,1958,329,439,1969,393,394,1929,396,1964,1927,1965,440,1966,1928,1973,1968,1963,327,1934,2000,2001,385,405,413,1970,1937,414,389,1972,1974,442,1936,326,441,322,1957))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "6.03",
              "prefix_cost": "138.42",
              "data_read_per_join": "482"
            },
            "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": 30,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "30.17",
              "eval_cost": "6.03",
              "prefix_cost": "174.63",
              "data_read_per_join": "482"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
322 339,338,355,374,376,349M,378,341,350,345,357,375,354,370,342,372,369,352,358,373,353,351,344,356,377,371 0
326 373,395,353,396,362,351,356,377,361,371,394,380,359,355,385,381,363,374,376,384,386,389,349M,378,382,350,383,357,390,375,354,392,391,360,370,368,388,393,372,369,352,379,358 0
327 360,370,372,369,352,379,358,373,353,362,351,356,377,361,371,380,359,355,385,381,363,374,376,384,386,349M,378,382,350,383,357,375,354 0
329 357,375,354,339,370,372,369,352,358,373,353,338,351,356,377,371,355,374,376,349M,378,342,350 0
382 349,378,344,342,350,357,375,340,343,354,379,339,370,372,369,352,358,373,353,338,351,356,377,371,341,345,385,381,355,337M,384,386,347,374,382,376,383 0
385 337M,347,368,388,393,374,376,395,349,360,378,396,344,342,350,394,357,375,362,340,343,354,361,339,370,372,369,352,358,373,353,338,359,351,356,377,371,363,341,345,390,392,355,391 0
389 384,386,382,355,383,337M,347,374,376,349,378,344,342,379,350,357,375,380,340,343,354,339,370,372,369,352,358,373,353,338,385,351,381,356,377,371,341,345 0
393 351,381,356,377,371,341,345,384,386,382,355,383,337M,347,374,376,349,378,344,342,379,350,357,375,380,340,343,354,339,370,372,369,352,358,373,353,338,385 0
394 372,369,352,358,373,353,338,385,351,381,356,377,371,341,345,384,386,382,355,383,337M,347,374,376,349,378,344,342,379,350,357,375,380,340,343,354,339,370 0
396 340,343,354,339,370,372,369,352,358,373,353,338,351,356,377,371,341,345,355,337M,347,374,376,349,378,344,342,350,357,375 0
405 344,342,390,350,357,392,375,391,340,343,354,368,388,393,339,370,372,369,395,352,360,396,358,373,353,338,394,351,356,377,362,371,341,361,345,355,337M,347,359,374,376,363,349,378 0
408 374,376,349,378,344,342,350,357,375,385,340,343,354,381,339,370,372,369,384,386,352,358,373,382,353,338,383,351,356,377,371,341,345,379,355,337M,347,380 0
413 355,363,337M,374,376,349,378,344,342,368,350,357,375,340,343,354,360,339,370,372,369,352,362,358,373,361,353,338,351,356,377,371,341,345,359 0
414 371,341,345,359,355,363,337M,374,376,349,378,344,342,368,350,357,375,340,343,354,360,339,370,372,369,352,362,358,373,361,353,338,351,356,377 0
418 358,373,353,338,351,356,377,371,341,345,355,363,337M,374,376,349,378,344,342,350,357,375,340,343,354,339,370,372,369,352 0
427 379,339,370,372,369,352,347,380,358,373,353,338,351,356,377,371,341,345,385,381,355,337M,384,386,374,376,382,349,378,383,344,342,350,357,375,340,343,354 0
439 362,350,357,361,375,340,343,354,379,339,370,372,369,352,359,358,373,353,338,351,377,371,341,345,363,385,381,368,355,337M,384,386,360,374,376,382,349,378,383,344,342 0
440 376,362,390,361,375,392,391,388,393,370,372,369,359M,395,373,396,377,394,371,363,368,360,374 0
441 382,349,383,344,342,360,350,357,340,343,354,347,380,362,361,339,352,356,358,353,338,370,351,372,369,359,341,345,371,381,355,363,337M,384,368 0
442 363,378,384,374,368,376,382,383,360,379,375,380,362,361,373,370,372,369,359M,377,385,371,381,386 0
1465 355,337,371,381,386,363,349,378,344,342,384,374,368,350,376,390,357,382,383,340,343,354,392,347,360,391,379,388,393,339,375,352,356,380,362,358,395,396,361M,353,338,351,394,341,373,345,370,372,369,359,377,385 0
1529 345,370,372,369,359,377,385,355,337,371,381,386,363,349M,378,344,342,384,374,368,350,376,390,357,340,343,354,392,347,360,391,379,388,393,339,375,352,356,380,362,358,395,396,361,353,338,351,394,341,373 0
1927 361M,353,338,351,345,370,369,359,377,337,363,349,378,374,350,390,340,391,379,339,362,358 0
1928 339,362,361M,338,345,370,369,359,381,349,378,374,350,390,391,395,379 0
1929 391,373,379,339,338,377,345,337,369,359,381,363M,388,349,352,350,390 0
1930 349,352,350,390,395,341,353,351,391,362,379,361M,339,355,338,377,345,376,337,369,359,354,381,363,375,340,356,388 0
1931 340,388,349,372,385,350,390,395,353,391,362,371,379,361M,339,342,338,360,345,376,337,369,359,381,374,380,363,396 0
1932 359,381,394,352,388,349,350,390,391,362M,384,379,339,377,338,378,345,369 0
1933 374,345,363,369,396,359,340,381,394,341,372,352,386,388,349,355,370,350,390,361M,391,362,379,339,360,338,376,337 0
1934 360,356,338,358,337,374,345,363,373,369,396,359,340,381,394,395,372,352,344,349,355,370,350,342,384,390,361M,377,391,362,354,379,339 0
1935 391,362,379,380,339,376,360,338,337,374,345,363,369,359,340,381,394,395,388,372,352,344,349,393,350,342,384,390,361M 0
1936 378,377,375,350,384,390,361M,391,362,356,379,339,376,360,338,341,337,373,396,353,374,345,386,363,369,359,381,394,395,388,370,352,349 0
1937 352,342,354,349,378,377,375,350,384,390,380,361M,358,391,362,351,356,379,385,339,376,382,360,338,371,341,337,373,368,396,353,340,357,374,345,343,386,392,363,347,369,359,355,372,381,394,344,395,388,370,393 0
1957 370,352,349,377,361M,362,379,339,331,360,338,337,368,340,363,369,359,381 0
1958 363,369,388,359,381,370,352,349,377,361M,362,379,339,360,338,337,368,340 0
1959 360,338,337,368,340,363,369,359,381,350,370,352,349,377,361M,362,379,339 0
1960 379,339,360,338,337,368,340,378,363,369,359,381,370,352,349,377,361M,362 0
1961 361M,362,379,339,360,338,337,368,340,378,350,363,369,359,381,370,349,377 0
1962 349,377,361M,388,362,379,339,390,360,338,337,340,350,363,369,359,381,352,370 0
1963 370,349,377,361M,388,362,379,339,360,378,338,337,340,350,363,369,359,381,352 0
1964 363,369,359,381,370,349,377,361M,368,362,379,339,360,378,338,337,340 0
1965 337,340,352,363,369,359,381,370,349,377,361M,368,362,379,339,360,338 0
1966 360,338,337,340,352,363,369,359,381,370,349,377,361M,368,362,379,339 0
1968 362,379,339,360,338,337,340,352,363,369,359,381,370,349,361M,350 0
1969 368,361M,350,362,379,339,360,338,337,340,352,363,369,359,381,370,349 0
1970 349,368,361M,350,362,379,339,360,338,337,340,352,363,369,359,381,377,370 0
1971 381,377,370,349,368,361M,350,362,379,339,360,338,337,340,352,363,369,359 0
1972 340,352,363,369,359,381,370,349,368,361M,350,362,379,339,360,338,337 0
1973 360,338,337,340,352,377,363,369,359,381,370,349,368,361M,362,379,339 0
1974 362,379,339,360,338,337,340,352,363,369,359,381,370,350,349,368,361M 0
2000 362,338,391,390,363,369,396M,349 0
2001 349,362,338,391,390,363,369,396M 0