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 = 370 
WHERE 
  cscart_products_categories.product_id IN (
    427, 408, 1971, 382, 418, 1959, 1960, 
    1961, 381, 1529, 1465, 1962, 1933, 1958, 
    329, 439, 1969, 393, 394, 396, 1964, 
    383, 1927, 1965, 440, 1966, 1928, 1973, 
    1968, 1963, 327, 1934, 385, 405, 413, 
    1970, 1937, 414, 389, 1972
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01185

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "193.08"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "24.85"
      },
      "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": 24,
            "filtered": "27.01",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (427,408,1971,382,418,1959,1960,1961,381,1529,1465,1962,1933,1958,329,439,1969,393,394,396,1964,383,1927,1965,440,1966,1928,1973,1968,1963,327,1934,385,405,413,1970,1937,414,389,1972))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "4.97",
              "prefix_cost": "138.42",
              "data_read_per_join": "397"
            },
            "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": 24,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "24.85",
              "eval_cost": "4.97",
              "prefix_cost": "168.24",
              "data_read_per_join": "397"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
327 385,386,359,380,361,375,355,383,379,378,373,371,350,377,374,382,351,360,370,353,349M,356,381,376,357,372,384,363,369,358,352,354,362 0
329 369,358,352,338,354,375,355,339,378,373,371,350,377,374,351,370,353,349M,356,376,357,372,342 0
381 341,337M,376,372,357,362,342,385,386,358,352,338,359,354,380,361,347,340,383,379,344,375,355,339,378,373,371,382,350,360,343,374,381,345,351,370,384,363,353,349,356 0
382 381,345,351,370,384,353,349,356,341,337M,376,369,372,357,342,385,386,358,352,338,354,347,340,383,379,344,375,355,377,339,378,373,371,382,350,343,374 0
383 371,350,343,374,363,381,345,351,370,384,362,353,349,356,341,337M,376,372,359,357,361,342,385,386,358,352,338,354,347,340,344,375,368,355,360,377,339,378,373 0
385 368,393,355,360,377,392,339,378,373,371,395,350,388,343,374,363,345,351,369,370,396,362,353,349,356,341,391,337M,376,372,359,357,361,342,358,352,338,354,347,390,340,394,344,375 0
389 382,340,344,375,355,377,339,378,373,371,381,350,343,374,380,384,345,351,369,370,353,349,356,385,341,386,337M,376,372,383,357,379,342,358,352,338,354,347 0
393 358,352,338,354,347,382,340,344,375,355,377,339,378,373,371,381,350,343,374,380,384,345,351,369,370,353,349,356,385,341,386,337M,376,372,383,357,379,342 0
394 372,383,357,379,342,358,352,338,354,347,382,340,344,375,355,377,339,378,373,371,381,350,343,374,380,384,345,351,369,370,353,349,356,385,341,386,337M,376 0
396 369,370,353,349,356,341,337M,376,372,357,342,358,352,338,354,347,340,344,375,355,377,339,378,373,371,350,343,374,345,351 0
405 343,374,394,345,351,369,368,393,360,370,392,353,349,356,341,337M,376,372,395,357,388,342,363,358,352,338,354,347,396,362,340,391,344,359,375,361,355,377,339,378,373,371,390,350 0
408 339,378,373,371,385,386,350,343,374,383,379,345,351,369,370,353,349,356,341,337M,376,382,372,357,342,358,352,338,354,347,381,340,344,375,380,384,355,377 0
413 344,375,355,377,339,378,373,371,350,368,343,374,360,345,351,369,370,353,349,356,341,363,337M,376,372,357,342,362,358,352,338,354,359,361,340 0
414 359,361,340,344,375,355,377,339,378,373,371,350,368,343,374,360,345,351,369,370,353,349,356,341,363,337M,376,372,357,342,362,358,352,338,354 0
418 342,358,352,338,354,340,344,375,355,377,339,378,373,371,350,343,374,345,351,369,370,353,349,356,341,363,337M,376,372,357 0
427 370,353,349,356,341,380,384,337M,376,372,357,342,385,358,386,352,338,354,383,379,340,344,375,355,377,382,339,378,373,371,350,343,374,347,345,351,369,381 0
439 345,362,363,351,369,381,370,353,349,341,359,384,361,337M,376,372,357,342,385,358,386,352,338,354,383,379,340,368,344,360,375,355,377,382,339,378,373,371,350,343,374 0
440 373,371,390,374,362,363,369,394,370,393,359M,392,361,376,372,395,388,396,368,391,360,375,377 0
1465 347,378,350,377,343,356,373,371,345,380,351,381,390,374,353,349,341,384,362,363,337,369,394,357,370,393,342,359,392,361M,376,385,358,372,386,352,338,354,383,395,379,388,340,344,355,396,368,382,339,391,360,375 0
1529 355,396,368,339,391,360,375,347,378,350,377,343,356,373,371,345,380,351,381,390,374,353,349M,341,384,362,363,337,369,394,357,370,393,342,359,392,361,376,385,358,372,386,352,338,354,395,379,388,340,344 0
1927 379,340,339,391,378,350,377,345,351,390,374,353,349,362,363,337,369,370,359,361M,358,338 0
1928 361M,338,379,339,391,378,350,381,345,390,374,349,362,369,370,395,359 0
1933 388,362,369,370,359,361M,340,355,396,338,360,379,339,391,341,350,381,394,345,363,337,376,390,374,372,386,352,349 0
1934 363,337,390,358,374,372,352,349,395,344,362,369,370,359,361M,340,355,396,338,360,379,356,373,377,384,339,391,342,350,381,394,354,345 0
1937 350,376,381,394,386,354,382,345,388,363,337,390,358,374,372,352,368,349,395,344,375,362,347,369,370,343,359,361M,371,340,355,380,396,338,360,379,356,378,373,351,377,357,393,353,341,384,392,385,339,391,342 0
1958 339,381,388,363,337,352,368,349,362,369,370,359,361M,340,338,360,379,377 0
1959 377,350,339,381,363,337,352,368,349,362,369,370,359,361M,340,338,360,379 0
1960 338,360,379,377,339,381,363,337,352,368,349,362,378,369,370,359,361M,340 0
1961 370,359,361M,340,338,360,379,350,377,339,381,363,337,368,349,362,378,369 0
1962 349,362,369,370,359,361M,340,338,390,360,379,388,350,377,339,381,352,363,337 0
1963 352,363,337,378,349,362,369,370,359,361M,340,338,360,379,388,350,377,339,381 0
1964 368,381,363,337,378,349,362,369,370,359,361M,340,338,360,379,377,339 0
1965 339,352,368,381,363,337,349,362,369,370,359,361M,340,338,360,379,377 0
1966 360,379,377,339,352,368,381,363,337,349,362,369,370,359,361M,340,338 0
1968 359,361M,340,338,360,379,339,352,381,363,337,350,349,362,369,370 0
1969 362,369,370,359,361M,340,338,360,379,368,339,352,381,363,337,350,349 0
1970 363,337,350,349,362,369,377,370,359,361M,340,338,360,379,368,339,352,381 0
1971 381,363,337,350,349,362,369,377,370,359,361M,340,338,360,379,368,339,352 0
1972 339,352,381,363,337,350,349,362,369,370,359,361M,340,338,360,379,368 0
1973 368,339,352,381,363,337,377,349,362,369,370,359,361M,340,338,360,379 0