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 = 347 
WHERE 
  cscart_products_categories.product_id IN (
    427, 408, 382, 400, 424, 381, 1529, 1465, 
    428, 391, 406, 390, 393, 394, 396, 397, 
    398, 399, 434, 383, 412, 432, 384, 395, 
    385, 405, 1937, 425, 407, 389, 402, 388, 
    409, 404, 387, 386, 441
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.02373

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "195.69"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "26.03"
      },
      "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": 26,
            "filtered": "28.29",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (427,408,382,400,424,381,1529,1465,428,391,406,390,393,394,396,397,398,399,434,383,412,432,384,395,385,405,1937,425,407,389,402,388,409,404,387,386,441))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "5.21",
              "prefix_cost": "138.42",
              "data_read_per_join": "416"
            },
            "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": 26,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "26.03",
              "eval_cost": "5.21",
              "prefix_cost": "169.66",
              "data_read_per_join": "416"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
381 372,378,339,385,361,363,350,360,354,338,376,386,344,358,371,352,343,342,379,375,380,381,347,357,362,353,349,341,374,359,370,345,356,384,337M,373,382,340,383,351,355 0
382 337M,373,382,340,383,369,351,355,372,378,339,377,385,350,354,338,376,386,344,358,371,352,343,342,379,375,381,347,357,353,349,341,374,370,345,356,384 0
383 374,370,345,356,384,368,337M,373,340,361,363,351,355,360,372,378,339,377,385,350,354,338,376,386,344,358,371,352,343,342,362,375,381,347,359,357,353,349,341 0
384 347,357,353,349,341,345,356,337M,340,351,355,339,350,354,338,344,358,352,343,342 0
385 359,352,343,342,391,374,347,357,370,369,394,353,349,368,341,373,390,345,356,361,363,337M,388,340,360,372,393,378,377,351,355,396,339,376,392,350,354,338,371,362,344,358,375,395 0
386 338,344,358,352,343,342,347,357,353,349,341,345,356,337M,340,351,355,339,350,354 0
387 339,350,354,338,344,358,352,343,342,347,357,353,349,341,345,356,337M,340,351,355 0
388 381,351,355,362,359,382,339,383,384,350,354,338,344,358,368,352,343,342,385,361,363,347,357,380,360,353,349,341,379,386,345,356,337M,340 0
389 345,356,371,337M,375,340,381,351,355,374,382,339,370,383,369,384,350,354,338,373,344,358,352,343,372,342,378,377,385,347,357,380,353,349,341,376,379,386 0
390 353,349,341,395,345,356,391,362,337M,340,359,351,355,394,339,390,368,350,354,338,388,393,344,358,361,363,352,343,360,396,342,347,357,392 0
391 342,347,357,353,349,341,345,356,337M,340,351,355,339,350,354,338,344,358,352,343 0
393 344,358,376,379,386,352,343,342,371,347,357,375,381,353,349,341,374,345,356,382,370,383,369,384,337M,340,373,351,355,339,372,378,377,385,350,354,338,380 0
394 372,378,377,385,350,354,338,380,344,358,376,379,386,352,343,342,371,347,357,375,381,353,349,341,374,345,356,382,370,383,369,384,337M,340,373,351,355,339 0
395 351,355,339,350,354,338,344,358,352,343,342,347,357,353,349,341,345,356,337M,340 0
396 337M,340,372,351,355,378,377,339,350,354,376,338,371,344,358,375,352,343,342,347,357,374,353,349,370,341,369,345,356,373 0
397 341,345,356,337M,340,351,355,339,350,354,338,344,358,352,343,342,347,357,353,349 0
398 396,347,357,392,353,349,341,389,345,356,395,337M,340,391,362,351,359,355,394,339,390,350,354,338,368,388,344,358,393,361,363,352,343,342,360 0
399 352,343,342,347,357,353,349,341,345,356,337M,340,351,355,339,350,354,338,344,358 0
400 350,354,338,344,358,352,343,342,347,357,353,349,341,345,356,337M,340,351,355,339 0
402 393,361,363,339,360,396,350,354,338,392,344,358,352,343,342,395,347,357,391,362,353,349,341,359,394,345,356,337M,390,340,368,351,355,388 0
404 340,351,355,339,350,354,338,344,358,352,343,342,347,357,353,349,341,345,356,337M 0
405 370,390,369,345,356,368,373,388,337M,393,340,361,363,351,355,360,372,396,378,377,339,392,350,354,338,376,395,344,358,371,352,343,391,362,342,375,359,347,357,394,353,349,374,341 0
406 394,353,349,341,390,345,356,368,388,337M,393,340,361,363,351,355,360,396,339,392,350,354,338,395,344,358,352,343,391,362,342,359,347,357 0
407 352,343,391,362,342,359,347,357,394,385,353,349,341,380,390,345,356,368,379,386,388,337M,393,340,361,363,351,355,360,381,396,339,392,350,354,382,338,383,384,395,344,358 0
408 383,384,344,358,374,370,352,343,369,342,373,347,357,385,353,349,341,380,372,378,345,356,377,379,386,337M,340,376,351,355,381,371,339,375,350,354,382,338 0
409 339,350,354,344,358,352,343,342,347,357,353,349,341,345,356,337M,340,351,355 0
412 351,355,338,339,350,354,344,358,352,343,342,347,357,353,349,341,345,356,337M,340 0
424 337M,340,351,355,338,339,350,354,344,358,352,343,342,347,357,353,349,341,345,356 0
425 353,349,341,345,356,337M,340,351,355,338,339,350,354,344,358,352,343,342,347,357 0
427 375,347,357,382,383,353,349,384,341,374,345,356,370,369,337M,340,373,351,355,385,380,338,372,339,378,377,379,386,350,354,344,358,376,381,352,343,371,342 0
428 344,358,395,352,343,342,391,362,347,357,359,353,349,394,341,345,356,390,368,337M,340,388,393,351,355,361,363,338,360,396,339,350,354,392 0
432 350,354,344,358,352,343,342,347,357,353,349,341,345,356,337M,340,351,355,338,339 0
434 338,381,339,350,354,382,383,344,358,384,362,352,343,359,342,347,357,353,349,341,368,385,380,345,356,361,363,337M,379,386,340,360,351,355 0
441 361,363,337M,340,360,371,351,355,338,381,339,350,354,382,370,383,344,358,369,384,362,352,343,359,342,347,357,372,353,349,341,368,380,345,356 0
1465 368,376,379,386,380,392,345,356,361M,363,337,340,375,395,360,371,351,355,391,338,374,381,339,394,350,354,373,382,370,383,390,344,358,369,384,362,352,343,359,388,342,393,378,377,385,347,357,372,396,353,349,341 0
1529 377,385,347,357,372,396,353,349M,341,368,376,379,386,380,392,345,356,361,363,337,340,375,395,360,371,351,355,391,338,374,381,339,394,350,354,373,370,390,344,358,369,384,362,352,343,359,388,342,393,378 0
1937 352,343,359,388,342,393,378,377,385,347,357,372,396,353,349,341,368,376,379,386,380,392,345,356,361M,363,337,340,375,395,360,371,351,355,391,338,374,381,339,382,394,350,354,373,370,390,344,358,369,384,362 0