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 = 359 
WHERE 
  cscart_products_categories.product_id IN (
    421, 443, 1971, 1959, 1930, 1960, 321, 
    436, 438, 437, 1961, 1931, 381, 1529, 
    1465, 1932, 1962, 1933, 1935, 1958, 
    428, 406, 439, 390, 1969, 1929, 398, 
    1964, 434, 383, 1927, 435, 419, 403, 
    324, 1965, 440, 1966, 431, 1928
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01027

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "185.83"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "21.55"
      },
      "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": 21,
            "filtered": "23.42",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (421,443,1971,1959,1930,1960,321,436,438,437,1961,1931,381,1529,1465,1932,1962,1933,1935,1958,428,406,439,390,1969,1929,398,1964,434,383,1927,435,419,403,324,1965,440,1966,431,1928))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "4.31",
              "prefix_cost": "138.42",
              "data_read_per_join": "344"
            },
            "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": 21,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "21.55",
              "eval_cost": "4.31",
              "prefix_cost": "164.28",
              "data_read_per_join": "344"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

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