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 = 339 
WHERE 
  cscart_products_categories.product_id IN (
    383, 412, 1927, 419, 430, 1965, 1966, 
    431, 432, 1928, 1973, 429, 1968, 384, 
    1963, 1934, 395, 420, 385, 405, 410, 
    413, 1970, 417, 1937, 414, 425, 407, 
    389, 402, 1972, 388, 426, 409, 1974, 
    404, 1936, 387, 386, 416
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00878

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "189.05"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "23.01"
      },
      "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": 23,
            "filtered": "25.01",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (383,412,1927,419,430,1965,1966,431,432,1928,1973,429,1968,384,1963,1934,395,420,385,405,410,413,1970,417,1937,414,425,407,389,402,1972,388,426,409,1974,404,1936,387,386,416))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "4.60",
              "prefix_cost": "138.42",
              "data_read_per_join": "368"
            },
            "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": 23,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "23.01",
              "eval_cost": "4.60",
              "prefix_cost": "166.04",
              "data_read_per_join": "368"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
383 375,361,377,345,347,357,353,360,378,371,373,339,341,338,354,374,368,356,337M,370,358,381,340,363,351,349,376,384,359,344,386,350,362,343,372,385,352,342,355 0
384 350,343,352,342,355,345,347,357,353,339,341,338,354,356,337M,358,340,351,349,344 0
385 362,372,344,350,396,343,375,352,342,361,355,377,392,360,378,371,395,345,347,373,357,391,353,374,368,390,393,339,369,341,370,338,354,363,376,356,337M,359,358,394,340,388,351,349 0
386 337M,358,340,351,349,344,350,343,352,342,355,345,347,357,353,339,341,338,354,356 0
387 341,338,354,356,337M,358,340,351,349,344,350,343,352,342,355,345,347,357,353,339 0
388 353,359,383,385,339,341,362,338,354,382,356,379,337M,358,340,351,349,361,360,344,350,343,352,342,381,355,368,384,363,345,347,380,357,386 0
389 345,347,380,357,386,353,383,372,385,339,341,375,338,354,382,356,377,379,337M,358,340,351,349,378,371,373,344,374,350,343,369,352,342,370,381,355,376,384 0
395 352,342,355,345,347,357,353,339,341,338,354,356,337M,358,340,351,349,344,350,343 0
402 394,344,388,363,350,343,352,342,359,355,396,362,345,347,357,353,392,361,339,395,341,391,338,354,360,356,337M,390,393,358,340,351,349,368 0
404 340,351,349,344,350,343,352,342,355,345,347,357,353,339,341,338,354,356,337M,358 0
405 338,354,370,356,337M,376,368,358,340,351,349,394,388,363,359,372,344,350,343,352,342,396,362,375,355,377,392,345,347,378,361,357,371,395,353,373,391,360,339,374,341,390,393,369 0
407 360,381,339,341,384,390,393,338,354,356,337M,368,380,358,386,340,383,351,349,385,394,388,363,359,344,382,350,343,379,352,342,396,362,355,392,345,347,361,357,395,353,391 0
409 345,347,357,353,339,341,354,356,337M,358,340,351,349,344,350,343,352,342,355 0
410 355,345,357,353,338,339,341,354,356,337M,358,340,351,349,344,350,343,352,342 0
412 344,350,343,352,342,355,347,345,357,353,338,339,341,354,356,337M,358,340,351,349 0
413 361,374,369,344,370,350,360,343,352,342,376,355,368,345,372,357,363,353,338,359,375,339,341,377,354,362,356,337M,378,358,371,340,373,351,349 0
414 356,337M,378,358,371,340,373,351,349,361,374,369,344,370,350,360,343,352,342,376,355,368,345,372,357,363,353,338,359,375,339,341,377,354,362 0
416 339,392,341,395,354,362,391,356,337M,358,340,390,393,351,349,361,344,350,360,394,343,388,352,342,355,368,396,345,357,363,353,338,359 0
417 357,353,338,339,341,354,356,337M,358,340,351,349,344,350,343,352,342,355,345 0
419 363,359,345,357,392,353,395,338,362,391,339,341,354,390,393,356,389,337M,361,358,340,351,349,360,394,388,344,350,343,352,342,368,355,396 0
420 343,352,342,355,345,357,353,338,339,341,354,356,337M,358,340,351,349,344,350 0
425 344,350,343,352,342,355,347,345,357,353,338,339,341,354,356,337M,358,340,351,349 0
426 358,340,351,349,377,378,381,371,344,373,384,350,343,352,342,374,355,386,370,383,385,376,345,357,353,382,338,379,339,341,372,354,356,337M,375 0
429 354,356,337M,358,340,351,349,344,350,343,352,342,355,345,357,353,338,339,341 0
430 338,339,341,354,356,337M,358,340,351,349,344,350,343,352,342,355,345,357,353 0
431 368,345,357,396,353,363,338,339,359,341,392,354,395,356,362,337M,391,358,351,349,390,393,361,344,350,343,352,342,360,394,388,355 0
432 355,345,357,353,338,339,341,347,340,354,356,337M,358,351,349,344,350,343,352,342 0
1927 350,377,363,378,345,359,353,369,338,374,339,362,391,370,340,390,337,358,361M,351,349,379 0
1928 361M,349,379,350,381,378,345,395,359,369,338,374,339,362,391,370,390 0
1934 344,390,352,342,361M,349,355,379,396,350,377,373,384,363,381,354,345,395,359,356,369,340,338,374,339,362,337,391,358,370,360,372,394 0
1936 374,388,339,362,337,391,370,360,375,394,390,352,361M,349,379,396,350,377,373,384,353,341,386,363,378,381,376,345,395,359,356,369,338 0
1937 351,345,395,359,356,369,343,358,338,372,374,388,344,339,368,362,337,391,370,342,360,375,394,355,390,371,357,380,352,361M,349,392,379,396,347,385,350,377,373,384,393,353,341,386,363,354,378,381,382,376,340 0
1963 340,359,369,338,388,339,362,337,370,360,352,361M,349,379,350,377,363,378,381 0
1965 377,363,381,340,359,368,369,338,339,362,337,370,360,352,361M,349,379 0
1966 379,377,363,381,340,359,368,369,338,339,362,337,370,360,352,361M,349 0
1968 350,352,361M,349,379,363,381,340,359,369,338,339,362,337,370,360 0
1970 362,337,370,360,350,352,361M,349,377,379,363,381,368,340,359,369,338,339 0
1972 369,338,339,362,337,370,360,350,352,361M,349,379,363,381,368,340,359 0
1973 340,359,369,338,339,362,337,370,360,377,352,361M,349,379,363,381,368 0
1974 363,381,368,340,359,369,338,339,362,350,337,370,360,352,361M,349,379 0