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

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