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

Query time 0.00958

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "188.48"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "22.75"
      },
      "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.73",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (421,443,1971,1959,1960,436,438,437,1961,1931,381,1529,1465,1962,1933,1935,1958,428,406,439,390,1969,398,1964,434,383,435,419,403,324,1965,440,1966,431,1973,1968,1963,327,1934,385))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "4.55",
              "prefix_cost": "138.42",
              "data_read_per_join": "364"
            },
            "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.75",
              "eval_cost": "4.55",
              "prefix_cost": "165.73",
              "data_read_per_join": "364"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

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