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 = 273 
WHERE 
  cscart_products_categories.product_id IN (
    3104, 3107, 6682, 6678, 104, 105, 106, 
    107, 108, 109, 110, 4013, 4014, 4015, 
    4016, 4017, 4018, 4019, 3105, 6677, 
    6686, 64, 118, 224, 225, 285, 3975, 4027, 
    4108, 4109, 4170, 4223, 203, 204, 205, 
    206, 207, 208, 209, 4087, 4088, 4089, 
    4090, 4091, 4092, 4093, 3122, 6675, 
    6696, 6703, 3118, 3111, 3124, 3112, 
    324, 6704, 6709, 4177, 338, 331, 6705, 
    3932, 3134, 3116, 3126, 6673, 6679, 
    6691, 3155, 3131, 310, 303, 3939, 317, 
    3132, 3143, 3130, 3129, 3121, 3128, 
    6681, 6695, 3098, 3115, 6690, 6700, 
    12, 13, 14, 15, 16, 17, 18, 65, 66, 67
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00273

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "68.37"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "1.53"
      },
      "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": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "gaseus.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 110,
            "rows_produced_per_join": 1,
            "filtered": "0.87",
            "index_condition": "(`gaseus`.`cscart_products_categories`.`product_id` in (3104,3107,6682,6678,104,105,106,107,108,109,110,4013,4014,4015,4016,4017,4018,4019,3105,6677,6686,64,118,224,225,285,3975,4027,4108,4109,4170,4223,203,204,205,206,207,208,209,4087,4088,4089,4090,4091,4092,4093,3122,6675,6696,6703,3118,3111,3124,3112,324,6704,6709,4177,338,331,6705,3932,3134,3116,3126,6673,6679,6691,3155,3131,310,303,3939,317,3132,3143,3130,3129,3121,3128,6681,6695,3098,3115,6690,6700,12,13,14,15,16,17,18,65,66,67))",
            "cost_info": {
              "read_cost": "44.00",
              "eval_cost": "0.15",
              "prefix_cost": "66.30",
              "data_read_per_join": "24"
            },
            "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",
              "gaseus.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 1,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "0.38",
              "eval_cost": "0.15",
              "prefix_cost": "66.84",
              "data_read_per_join": "24"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
12 273M 0
13 273M 0
14 273M 0
15 273M 0
16 273M 0
17 273M 0
18 273M 0
64 273M 0
65 273M 0
66 273M 0
67 273M 0
104 273M 0
105 273M 0
106 273M 0
107 273M 0
108 273M 0
109 273M 0
110 273M 0
118 273M 0
203 273M 0
204 273M 0
205 273M 0
206 273M 0
207 273M 0
208 273M 0
209 273M 0
224 273M 0
225 273M 0
285 273M 0
303 273M 0
310 273M 0
317 273M 0
324 273M 0
331 273M 0
338 273M 0
3098 273M 0
3104 273M 0
3105 273M 0
3107 273M 0
3111 273M 0
3112 273M 0
3115 273M 0
3116 273M 0
3118 273M 0
3121 273M 0
3122 273M 0
3124 273M 0
3126 273M 0
3128 273M 0
3129 273M 0
3130 273M 0
3131 273M 0
3132 273M 0
3134 273M 0
3143 273M 0
3155 273M 0
3932 273M 0
3939 273M 0
3975 273M 0
4013 273M 0
4014 273M 0
4015 273M 0
4016 273M 0
4017 273M 0
4018 273M 0
4019 273M 0
4027 273M 0
4087 273M 0
4088 273M 0
4089 273M 0
4090 273M 0
4091 273M 0
4092 273M 0
4093 273M 0
4108 273M 0
4109 273M 0
4170 273M 0
4177 273M 0
4223 273M 0
6673 273M 0
6675 273M 0
6677 273M 0
6678 273M 0
6679 273M 0
6681 273M 0
6682 273M 0
6686 273M 0
6690 273M 0
6691 273M 0
6695 273M 0
6696 273M 0
6700 273M 0
6703 273M 0
6704 273M 0
6705 273M 0
6709 273M 0