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
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01120

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "187.70"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "22.40"
      },
      "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": 22,
            "filtered": "24.35",
            "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))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "4.48",
              "prefix_cost": "138.42",
              "data_read_per_join": "358"
            },
            "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": 22,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "22.40",
              "eval_cost": "4.48",
              "prefix_cost": "165.30",
              "data_read_per_join": "358"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

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