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 = 350 
WHERE 
  cscart_products_categories.product_id IN (
    421, 427, 408, 1971, 382, 418, 1959, 1930, 
    400, 424, 1961, 1931, 381, 1529, 1465, 
    1932, 1962, 1933, 1935, 428, 415, 391, 
    406, 329, 439, 390, 1969, 393, 394, 1929, 
    396, 397, 398, 399, 422, 434, 383, 412, 
    1927, 419
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00910

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "193.52"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "25.04"
      },
      "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": 25,
            "filtered": "27.22",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (421,427,408,1971,382,418,1959,1930,400,424,1961,1931,381,1529,1465,1932,1962,1933,1935,428,415,391,406,329,439,390,1969,393,394,1929,396,397,398,399,422,434,383,412,1927,419))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "5.01",
              "prefix_cost": "138.42",
              "data_read_per_join": "400"
            },
            "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": 25,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "25.04",
              "eval_cost": "5.01",
              "prefix_cost": "168.48",
              "data_read_per_join": "400"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
329 342,375,372,358,374,354,377,376,339,356,350,371,338,378,370,352,355,351,357,373,369,349M,353 0
381 373,349,384,353,344,385,361,343,363,342,375,372,380,382,360,358,374,354,345,341,359,376,362,339,356,383,350,340,371,347,379,381,338,378,370,352,355,351,337M,386,357 0
382 338,369,378,370,352,355,351,337M,386,357,373,349,384,353,344,385,343,342,375,372,377,382,358,374,354,345,341,376,339,356,383,350,340,371,347,379,381 0
383 350,340,371,347,381,338,378,370,352,355,351,337M,386,361,357,363,373,349,384,353,344,385,343,368,342,375,360,372,377,359,358,374,354,362,345,341,376,339,356 0
390 339,356,350,340,347,338,392,352,355,351,337M,396,361,357,363,390,349,353,344,393,343,368,342,360,395,359,358,388,354,362,345,341,391,394 0
391 354,345,341,339,356,350,340,347,338,352,355,351,337M,357,349,353,344,343,342,358 0
393 379,358,354,371,369,345,341,381,378,370,339,356,380,386,350,340,373,384,382,385,347,338,375,372,352,355,377,351,337M,357,349,374,353,344,343,342,383,376 0
394 353,344,343,342,383,376,379,358,354,371,369,345,341,381,378,370,339,356,380,386,350,340,373,384,382,385,347,338,375,372,352,355,377,351,337M,357,349,374 0
396 352,355,377,351,337M,357,349,374,353,344,343,342,376,358,354,371,369,345,341,378,370,339,356,350,340,373,347,338,375,372 0
397 347,338,352,355,351,337M,357,349,353,344,343,342,358,354,345,341,339,356,350,340 0
398 339,356,362,350,340,391,394,389,347,338,352,355,351,337M,357,349,353,344,392,343,342,396,361,363,390,393,358,368,354,360,395,345,341,359,388 0
399 345,341,339,356,350,340,347,338,352,355,351,337M,357,349,353,344,343,342,358,354 0
400 358,354,345,341,339,356,350,340,347,338,352,355,351,337M,357,349,353,344,343,342 0
406 343,395,342,359,388,362,358,354,391,394,345,341,339,356,350,340,392,347,338,396,361,363,352,355,390,351,337M,357,393,349,368,353,344,360 0
408 357,349,353,344,375,372,343,377,342,383,374,358,354,379,376,345,341,381,339,356,371,369,380,350,340,386,347,378,370,384,382,385,338,352,355,373,351,337M 0
412 338,352,355,351,337M,357,349,353,344,343,342,358,354,345,341,339,356,350,340,347 0
415 350,340,338,352,355,351,337M,357,349,353,344,343,342,358,354,345,341,339,356 0
418 339,356,373,350,340,375,372,377,338,352,355,351,337M,374,357,349,353,344,376,343,342,371,369,358,354,363,345,341,378,370 0
419 358,354,393,368,363,345,341,360,395,339,359,356,388,389,362,350,340,391,394,338,352,355,351,337M,357,349,353,344,343,392,342,396,361,390 0
421 396,361,390,358,354,393,368,363,345,341,360,395,339,359,356,388,362,350,340,391,394,338,352,355,351,337M,357,349,353,344,343,392,342 0
422 349,353,344,343,342,358,354,345,341,339,356,350,340,338,352,355,351,337M,357 0
424 352,355,351,337M,357,347,349,353,344,343,342,358,354,345,341,339,356,350,340,338 0
427 382,385,338,378,370,352,355,351,337M,357,373,347,349,353,344,343,375,383,342,372,377,379,374,358,354,381,345,341,376,380,339,356,386,371,369,350,340,384 0
428 339,356,392,350,340,396,361,390,338,352,355,393,351,337M,368,363,357,347,360,349,395,353,344,343,359,342,388,362,391,394,358,354,345,341 0
434 380,386,345,341,384,382,385,339,356,350,340,361,338,352,355,351,337M,368,363,357,383,347,360,349,353,344,343,359,379,342,362,381,358,354 0
439 381,358,371,369,354,386,345,341,378,370,384,382,385,339,373,350,340,361,375,338,372,377,352,355,351,337M,368,363,357,383,360,374,349,353,344,343,359,379,342,376,362 0
1465 343,359,379,342,376,362,380,381,358,371,369,392,354,356,386,396,345,341,390,378,370,384,382,385,339,393,373,350,340,395,361M,375,347,338,372,388,377,352,355,351,337,368,363,357,383,360,374,391,394,349,353,344 0
1529 351,337,368,363,357,360,374,391,394,349M,353,344,343,359,379,342,376,362,380,381,358,371,369,392,354,356,386,396,345,341,390,378,370,384,385,339,393,373,350,340,395,361,375,347,338,372,388,377,352,355 0
1927 361M,338,377,351,337,363,374,391,349,353,359,379,362,358,369,345,390,378,370,339,350,340 0
1929 350,388,352,338,377,337,363M,391,349,359,379,381,369,345,373,390,339 0
1930 345,375,390,340,339,355,361M,350,388,352,351,338,376,377,353,337,363,391,349,362,354,359,356,379,381,341,369,395 0
1931 369,372,395,345,390,340,360,339,361M,350,342,374,388,380,338,376,371,353,337,363,396,391,349,362,385,359,379,381 0
1932 369,394,345,390,352,339,350,388,377,338,384,391,349,362M,378,359,379,381 0
1933 391,349,362,359,379,381,372,355,369,340,360,394,361M,345,390,374,352,339,386,350,376,388,337,363,396,341,338,370 0
1935 338,391,349,362,395,344,359,379,381,372,369,340,342,360,394,361M,345,380,390,374,352,339,393,350,376,388,384,337,363 0
1959 350,370,337,363,338,368,349,362,359,379,381,369,340,360,377,361M,352,339 0
1961 339,378,350,370,337,363,338,368,349,362,359,379,381,369,340,360,377,361M 0
1962 340,360,388,377,352,361M,339,350,370,337,363,338,349,362,359,379,381,390,369 0
1969 369,340,360,352,361M,339,350,368,370,337,363,338,349,362,359,379,381 0
1971 362,359,379,381,377,369,340,360,352,361M,339,350,368,370,337,363,338,349 0