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 = 7230 
WHERE 
  cscart_products_categories.product_id IN (
    86866, 86300, 86326, 86270, 86291, 86299, 
    86325, 86244, 86269, 86290, 86292, 
    86318, 87736, 86346, 86350, 86256, 
    86309, 86369, 86374, 86298, 86324, 
    86311, 86327, 86260, 86308, 86243, 
    86378, 86246, 86268, 86289, 86304, 
    86317, 86373, 86347, 86351, 86344, 
    86348, 86376, 86303, 86316, 86254, 
    86306, 86371, 86313, 86329, 86312, 
    86328, 86245, 86345, 86349, 86259, 
    86307, 86297, 86323, 86273, 86305, 
    86377, 86296, 86322, 86372, 86375, 
    86267, 86288, 86340, 86341, 86266, 
    86287, 86302, 86315, 86294, 86320, 
    86295, 86301, 86314, 86321, 86264, 
    86285, 86265, 86286, 86293, 86319, 
    86263, 86284, 95152, 95153, 95154, 
    95155, 95156, 95157, 95158, 95165, 
    95166, 95167, 95168, 95169, 95170
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01187

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "110.10"
    },
    "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": 122,
            "rows_produced_per_join": 122,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "12.50",
              "eval_cost": "12.20",
              "prefix_cost": "24.70",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (86866,86300,86326,86270,86291,86299,86325,86244,86269,86290,86292,86318,87736,86346,86350,86256,86309,86369,86374,86298,86324,86311,86327,86260,86308,86243,86378,86246,86268,86289,86304,86317,86373,86347,86351,86344,86348,86376,86303,86316,86254,86306,86371,86313,86329,86312,86328,86245,86345,86349,86259,86307,86297,86323,86273,86305,86377,86296,86322,86372,86375,86267,86288,86340,86341,86266,86287,86302,86315,86294,86320,86295,86301,86314,86321,86264,86285,86265,86286,86293,86319,86263,86284,95152,95153,95154,95155,95156,95157,95158,95165,95166,95167,95168,95169,95170))"
          }
        },
        {
          "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",
              "nuie_scalesta_net.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 122,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "30.50",
              "eval_cost": "12.20",
              "prefix_cost": "67.40",
              "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": [
              "nuie_scalesta_net.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 6,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "30.50",
              "eval_cost": "0.61",
              "prefix_cost": "110.10",
              "data_read_per_join": "15K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`nuie_scalesta_net`.`cscart_categories`.`storefront_id` in (0,1)) and ((`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`))) and (`nuie_scalesta_net`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
86243 7228,7230M 0
86244 7228,7230M 0
86245 7228,7230M 0
86246 7228,7230M 0
86254 7231M
86256 7231M
86259 7234M
86260 7231M
86263 7234M
86264 7231M
86265 7234M
86266 7231M
86267 7234M
86268 7231M
86269 7231M
86270 7231M
86273 7231M
86284 7234M
86285 7231M
86286 7234M
86287 7231M
86288 7234M
86289 7231M
86290 7231M
86291 7231M
86292 7231M
86293 7234M
86294 7231M
86295 7234M
86296 7231M
86297 7234M
86298 7231M
86299 7231M
86300 7231M
86301 7234M
86302 7234M
86303 7231M
86304 7231M
86305 7231M
86306 7231M
86307 7234M
86308 7231M
86309 7231M
86311 7231M
86312 7231M
86313 7234M
86314 7234M
86315 7234M
86316 7231M
86317 7231M
86318 7231M
86319 7234M
86320 7231M
86321 7234M
86322 7231M
86323 7234M
86324 7231M
86325 7231M
86326 7231M
86327 7231M
86328 7231M
86329 7234M
86340 7231M
86341 7231M
86344 7231M
86345 7231M
86346 7231M
86347 7231M
86348 7231M
86349 7231M
86350 7231M
86351 7231M
86369 7228,7230,7233M 0
86371 7228,7230,7236M 0
86372 7228,7230,7236M 0
86373 7228,7230,7236M 0
86374 7228,7230,7236M 0
86375 7228,7230,7236M 0
86376 7228,7230,7236M 0
86377 7228,7230,7236M 0
86378 7228,7230,7236M 0
86866 7228,7230,7233M 0
87736 7228,7230,7233M 0
95152 7231M
95153 7231M
95154 7231M
95155 7231M
95156 7231M
95157 7231M
95158 7231M
95165 7234M
95166 7231M
95167 7231M
95168 7234M
95169 7231M
95170 7231M