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.storefront_id IN (0, 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 = 308 
WHERE 
  cscart_products_categories.product_id IN (
    6198, 6199, 6200, 6732, 2836, 2837, 2838, 
    2839, 2840, 6422, 6423, 6424, 6425, 
    2937, 2938, 2939, 2940, 2941, 6522, 
    6523, 6524, 6525, 2189, 2190, 2191, 
    2192, 2193, 2194, 2195, 2196, 2197, 
    2720, 2721, 2722, 2723, 2769, 2770, 
    2771, 2772, 2773, 2774, 2775, 2776, 
    2777, 2845, 2846, 2847, 2848
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00164

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "69.97"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "8.00"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 40,
            "rows_produced_per_join": 1,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "4.54",
              "eval_cost": "0.16",
              "prefix_cost": "4.70",
              "data_read_per_join": "6K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`gaseus`.`cscart_categories`.`storefront_id` in (0,1)) and ((`gaseus`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`gaseus`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`gaseus`.`cscart_categories`.`usergroup_ids`))) and (`gaseus`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 50,
            "rows_produced_per_join": 8,
            "filtered": "10.00",
            "index_condition": "(`gaseus`.`cscart_products_categories`.`product_id` in (6198,6199,6200,6732,2836,2837,2838,2839,2840,6422,6423,6424,6425,2937,2938,2939,2940,2941,6522,6523,6524,6525,2189,2190,2191,2192,2193,2194,2195,2196,2197,2720,2721,2722,2723,2769,2770,2771,2772,2773,2774,2775,2776,2777,2845,2846,2847,2848))",
            "using_join_buffer": "hash join",
            "cost_info": {
              "read_cost": "47.22",
              "eval_cost": "0.80",
              "prefix_cost": "59.92",
              "data_read_per_join": "128"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`gaseus`.`cscart_products_categories`.`category_id` = `gaseus`.`cscart_categories`.`category_id`)"
          }
        },
        {
          "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",
              "gaseus.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 8,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.25",
              "eval_cost": "0.80",
              "prefix_cost": "61.97",
              "data_read_per_join": "128"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
2189 308M 0
2190 308M 0
2191 308M 0
2192 308M 0
2193 308M 0
2194 308M 0
2195 308M 0
2196 308M 0
2197 308M 0
2720 308M 0
2721 308M 0
2722 308M 0
2723 308M 0
2769 308M 0
2770 308M 0
2771 308M 0
2772 308M 0
2773 308M 0
2774 308M 0
2775 308M 0
2776 308M 0
2777 308M 0
2836 308M 0
2837 308M 0
2838 308M 0
2839 308M 0
2840 308M 0
2845 308M 0
2846 308M 0
2847 308M 0
2848 308M 0
2937 308M 0
2938 308M 0
2939 308M 0
2940 308M 0
2941 308M 0
6198 308M 0
6199 308M 0
6200 308M 0
6422 308M 0
6423 308M 0
6424 308M 0
6425 308M 0
6522 308M 0
6523 308M 0
6524 308M 0
6525 308M 0
6732 308M 0