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 = 2851 
WHERE 
  cscart_products_categories.product_id IN (
    415288, 269868, 269870, 265423, 265427, 
    265433, 265422, 265411, 270140, 269842, 
    269869, 269838, 265431, 269871, 269853, 
    269845, 269872, 269860, 269867, 265430, 
    265412, 269843, 269835, 265403, 265414, 
    270143, 269840, 265419, 265413, 265424, 
    269848, 392318, 269851, 270139, 269863, 
    269837, 269865, 270155, 270141, 392269, 
    270142, 270144, 265428, 265408, 392330, 
    265401, 265420, 392264, 265465, 392324, 
    392270, 392272, 392314, 392325, 392273, 
    392329, 392317, 392326, 392332, 392333, 
    392335, 392313, 392319, 392320, 392328, 
    392262, 392323, 392316, 392271, 392331, 
    392266, 392268, 392274, 392275, 392327, 
    392321, 392334, 392315, 392322, 392312
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00317

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "225.12"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 80,
            "rows_produced_per_join": 80,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "17.13",
              "eval_cost": "16.00",
              "prefix_cost": "33.13",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (415288,269868,269870,265423,265427,265433,265422,265411,270140,269842,269869,269838,265431,269871,269853,269845,269872,269860,269867,265430,265412,269843,269835,265403,265414,270143,269840,265419,265413,265424,269848,392318,269851,270139,269863,269837,269865,270155,270141,392269,270142,270144,265428,265408,392330,265401,265420,392264,265465,392324,392270,392272,392314,392325,392273,392329,392317,392326,392332,392333,392335,392313,392319,392320,392328,392262,392323,392316,392271,392331,392266,392268,392274,392275,392327,392321,392334,392315,392322,392312))"
          }
        },
        {
          "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",
              "webmarco.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 80,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "80.00",
              "eval_cost": "16.00",
              "prefix_cost": "129.13",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "webmarco.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "80.00",
              "eval_cost": "0.80",
              "prefix_cost": "225.13",
              "data_read_per_join": "23K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`webmarco`.`cscart_categories`.`storefront_id` in (0,1)) and ((`webmarco`.`cscart_categories`.`usergroup_ids` = '') or find_in_set(0,`webmarco`.`cscart_categories`.`usergroup_ids`) or find_in_set(1,`webmarco`.`cscart_categories`.`usergroup_ids`)) and (`webmarco`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
265401 2851M 0
265403 2851M 0
265408 2851M 0
265411 2851M 0
265412 2851M 0
265413 2851M 0
265414 2851M 0
265419 2851M 0
265420 2851M 0
265422 2851M 0
265423 2851M 0
265424 2851M 0
265427 2851M 0
265428 2851M 0
265430 2851M 0
265431 2851M 0
265433 2851M 0
265465 2851M 0
269835 2851M 0
269837 2851M 0
269838 2851M 0
269840 2851M 0
269842 2851M 0
269843 2851M 0
269845 2851M 0
269848 2851M 0
269851 2851M 0
269853 2851M 0
269860 2851M 0
269863 2851M 0
269865 2851M 0
269867 2851M 0
269868 2851M 0
269869 2851M 0
269870 2851M 0
269871 2851M 0
269872 2851M 0
270139 2851M 0
270140 2851M 0
270141 2851M 0
270142 2851M 0
270143 2851M 0
270144 2851M 0
270155 2851M 0
392262 2851M 0
392264 2851M 0
392266 2851M 0
392268 2851M 0
392269 2851M 0
392270 2851M 0
392271 2851M 0
392272 2851M 0
392273 2851M 0
392274 2851M 0
392275 2851M 0
392312 2851M 0
392313 2851M 0
392314 2851M 0
392315 2851M 0
392316 2851M 0
392317 2851M 0
392318 2851M 0
392319 2851M 0
392320 2851M 0
392321 2851M 0
392322 2851M 0
392323 2851M 0
392324 2851M 0
392325 2851M 0
392326 2851M 0
392327 2851M 0
392328 2851M 0
392329 2851M 0
392330 2851M 0
392331 2851M 0
392332 2851M 0
392333 2851M 0
392334 2851M 0
392335 2851M 0
415288 2851M 0