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

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