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 = 362 
WHERE 
  cscart_products_categories.product_id IN (
    413, 1970, 1937, 433, 414, 407, 402, 1972, 
    388, 1974, 442, 1956, 1936, 416, 326, 
    441, 1957
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00483

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "162.13"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "10.77"
      },
      "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": 10,
            "filtered": "11.71",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (413,1970,1937,433,414,407,402,1972,388,1974,442,1956,1936,416,326,441,1957))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "2.15",
              "prefix_cost": "138.42",
              "data_read_per_join": "172"
            },
            "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": 10,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "10.77",
              "eval_cost": "2.15",
              "prefix_cost": "151.35",
              "data_read_per_join": "172"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
326 357,376,355,368,389,361,359,392,388,349M,391,386,390,363,352,369,384,358,379,356,385,350,351,383,396,362,360,354,370,382,395,371,394,377,372,353,378,373,374,381,393,375,380 0
388 381,380,344,337M,357,355,368,361,359,341,349,347,343,386,339,363,340,352,384,358,379,356,385,350,351,342,383,362,360,354,382,353,345,338 0
402 393,353,345,338,392,344,337M,357,388,355,391,368,390,361,359,341,349,347,343,339,363,340,352,358,396,356,395,350,394,351,342,362,360,354 0
407 350,394,351,342,362,360,354,381,393,353,345,338,380,392,344,337M,357,388,355,391,368,386,390,361,359,341,349,384,347,343,339,379,363,340,385,352,358,383,396,356,382,395 0
413 358,374,356,375,350,376,351,342,362,360,354,353,345,338,369,344,337M,357,355,368,361,359,341,370,349,343,371,339,363,340,377,372,352,378,373 0
414 343,371,339,363,340,377,372,352,378,373,358,374,356,375,350,376,351,342,362,360,354,353,345,338,369,344,337M,357,355,368,361,359,341,370,349 0
416 368,396,361,359,341,395,349,343,394,339,363,340,352,358,356,393,350,351,342,362,360,354,392,388,391,353,390,345,338,344,337M,357,355 0
433 368,361,359M,363,362,360 0
441 383,344,337M,357,370,382,355,371,372,341,349,343,368,339,361,340,359,381,352,380,358,363,356,350,351,342,354,369,384,347,362,353,360,345,338 0
442 362,360,383,377,370,382,378,373,371,374,372,375,376,368,361,359M,381,380,363,386,379,385,369,384 0
1936 353,379,345,338,369,384,362,360,396,337,395,394,377,341,370,349,378,373,339,374,375,352,376,361M,359,356,381,350,388,391,363,386,390 0
1937 363,347,386,390,385,353,379,345,338,344,357,355,369,384,362,360,396,337,382,395,343,371,394,340,377,372,393,341,370,349,378,373,368,339,358,374,375,352,380,392,376,351,342,361M,359,356,381,354,350,388,391 0
1956 362M 0
1957 361M,331,359,381,363,379,338,369,360,337,362,340,377,370,349,368,339,352 0
1970 352,350,361M,359,381,363,379,338,369,360,337,362,340,377,370,349,368,339 0
1972 340,370,349,368,339,352,350,361M,359,381,363,379,338,369,360,337,362 0
1974 337,362,340,370,349,368,339,352,350,361M,359,381,363,379,338,369,360 0