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 = 344 
WHERE 
  cscart_products_categories.product_id IN (
    421, 427, 408, 382, 418, 400, 424, 381, 
    1529, 401, 1465, 1935, 428, 415, 391, 
    406, 439, 390, 393, 394, 396, 397, 398, 
    399
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00679

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "175.37"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "16.79"
      },
      "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": 16,
            "filtered": "18.25",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (421,427,408,382,418,400,424,381,1529,401,1465,1935,428,415,391,406,439,390,393,394,396,397,398,399))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "3.36",
              "prefix_cost": "138.42",
              "data_read_per_join": "268"
            },
            "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": 16,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "16.79",
              "eval_cost": "3.36",
              "prefix_cost": "158.58",
              "data_read_per_join": "268"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

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