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

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