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

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 384,352,350,361,353,357,378,354,363,380,386,374,382,362,370,379,349M,359,358,369,360,377,376,372,383,356,381,375,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,385,372,356,375,384,351,371,373,355,352,350,337M,340,341,353,345,344,357,378,386,354,338,382,343,379,374,370,349,383,358,347,381,342,369 0
385 388,396,349,394,358,347,393,342,369,339,377,376,390,372,356,361,375,351,371,392,373,355,395,352,350,363,337M,340,341,362,353,345,344,357,378,359,354,338,343,391,360,368,374,370 0
393 383,374,381,370,385,349,358,347,342,369,384,339,377,376,372,356,375,351,371,373,380,355,352,350,337M,386,340,341,382,353,345,344,379,357,378,354,338,343 0
394 379,357,378,354,338,343,383,374,381,370,385,349,358,347,342,369,384,339,377,376,372,356,375,351,371,373,380,355,352,350,337M,386,340,341,382,353,345,344 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 391,360,373,355,368,352,350,388,396,337M,394,340,341,393,353,345,344,390,357,378,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,386,375,351,371,382,373,379,355,352,350,337M,383,340,341,381,353,345,344,385,357,378,354,338,343,384,374,370,349,358,380,347,342,369,339,377,376,372 0
413 358,342,359,369,339,377,376,372,360,356,368,375,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,380,347,338,343,374,386,370,382,349,358,379,342,369,339,377,376,372,356,383,375,351,371,381,373,385,355,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,368,386,370,382,349,358,379,342,369,339,377,376,372,383,375,351,371,381,361,373,385,355,352,350,384,337M 0
440 391,362,363,388,396,394,359M,393,360,390,374,368,370,392,369,377,376,372,395,375,371,361,373 0
1465 375,352,350,371,361M,384,373,337,380,347,340,341,353,345,344,357,378,391,354,338,343,362,363,388,396,386,394,359,382,393,349,360,356,358,379,390,374,368,342,370,339,392,383,369,351,377,376,381,372,395,385,355 0
1529 369,351,377,376,381,372,395,385,355,375,352,350,371,361,384,373,337,380,347,340,341,353,345,344,357,378,391,354,338,343,362,363,388,396,386,394,359,393,349M,360,356,358,379,390,374,368,342,370,339,392 0
1927 370,339,369,351,377,350,361M,337,340,353,345,378,391,338,362,363,359,349,358,379,390,374 0
1928 359,349,379,390,374,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,388,356 0
1931 342,388,345,362,363,372,391,385,338,374,376,371,359,380,349,395,379,390,339,381,369,396,340,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 381,394,361M,337,369,360,350,370,363,372,388,355,374,345,376,362,391,338,341,359,352,386,349,379,390,396,339,340 0
1934 349,379,390,356,358,396,339,340,381,394,361M,342,337,369,360,350,370,363,344,372,384,373,355,374,345,362,391,395,338,354,377,359,352 0
1935 359,352,349,379,390,339,340,381,394,361M,342,337,369,360,388,350,380,376,363,344,372,384,374,345,362,391,395,393,338 0
1958 368,362,338,359,352,349,379,339,340,381,361M,337,369,360,370,388,363,377 0
1959 363,377,368,362,338,359,352,349,379,339,340,381,361M,337,369,360,350,370 0
1960 378,363,377,368,362,338,359,352,349,379,339,340,381,361M,337,369,360,370 0
1961 337,369,360,370,378,363,377,368,362,338,359,349,379,350,339,340,381,361M 0
1962 379,350,339,340,381,361M,337,369,360,370,390,363,377,362,338,352,388,359,349 0
1963 388,359,349,379,350,339,340,381,361M,337,369,360,378,370,363,377,362,338,352 0
1964 338,359,349,379,339,340,381,361M,337,369,360,378,370,368,363,377,362 0
1965 352,377,362,338,359,349,379,339,340,381,361M,337,369,360,370,368,363 0
1966 363,352,377,362,338,359,349,379,339,340,381,361M,337,369,360,370,368 0
1968 370,363,352,350,362,338,359,349,379,339,340,381,361M,337,369,360 0
1969 339,340,381,361M,368,337,369,360,370,363,352,350,362,338,359,349,379 0
1971 349,379,339,340,381,361M,368,337,369,360,370,377,363,352,350,362,338,359 0
1973 359,349,379,339,340,381,361M,368,337,369,360,370,377,363,352,362,338 0
2000 391,362,338,396M,349,390,369,363 0
2001 363,391,362,338,396M,349,390,369 0