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 = 7165 
WHERE 
  cscart_products_categories.product_id IN (
    94215, 94216, 94217, 94218, 94219, 94220, 
    94221, 94222, 94223, 94224, 94225, 
    94226, 94227, 94228, 94229, 94230, 
    94231, 94232, 94233, 94234, 94235, 
    94236, 94237, 94238, 94239, 94240, 
    94241, 94242, 94243, 94244, 94245, 
    94246, 94247, 94248, 94249, 94250, 
    94251, 94252, 94253, 94254, 94255, 
    94256, 94257, 94258, 94259, 94260, 
    94261, 94262, 94263, 94264, 94265, 
    94266, 94267, 94268, 94269, 94270, 
    94271, 94272, 94273, 94274, 94275, 
    94276, 94277, 94278, 94279, 94280, 
    94281, 94282, 94283, 94284, 94285, 
    94286, 94287, 94288, 94289, 94290, 
    94291, 94292, 94293, 94294, 94295, 
    94296, 94297, 94298, 94299, 94300, 
    94301, 94302, 94303, 94304, 94305, 
    94306, 94307, 94308, 94309, 94310
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00653

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "86.69"
    },
    "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": 96,
            "rows_produced_per_join": 96,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "9.89",
              "eval_cost": "9.60",
              "prefix_cost": "19.49",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (94215,94216,94217,94218,94219,94220,94221,94222,94223,94224,94225,94226,94227,94228,94229,94230,94231,94232,94233,94234,94235,94236,94237,94238,94239,94240,94241,94242,94243,94244,94245,94246,94247,94248,94249,94250,94251,94252,94253,94254,94255,94256,94257,94258,94259,94260,94261,94262,94263,94264,94265,94266,94267,94268,94269,94270,94271,94272,94273,94274,94275,94276,94277,94278,94279,94280,94281,94282,94283,94284,94285,94286,94287,94288,94289,94290,94291,94292,94293,94294,94295,94296,94297,94298,94299,94300,94301,94302,94303,94304,94305,94306,94307,94308,94309,94310))"
          }
        },
        {
          "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": 96,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "24.00",
              "eval_cost": "9.60",
              "prefix_cost": "53.09",
              "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": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "24.00",
              "eval_cost": "0.48",
              "prefix_cost": "86.69",
              "data_read_per_join": "12K"
            },
            "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
94215 7166M
94216 7166M
94217 7166M
94218 7166M
94219 7166M
94220 7166M
94221 7166M
94222 7166M
94223 7166M
94224 7166M
94225 7166M
94226 7166M
94227 7166M
94228 7166M
94229 7166M
94230 7166M
94231 7166M
94232 7166M
94233 7166M
94234 7166M
94235 7166M
94236 7166M
94237 7166M
94238 7166M
94239 7166M
94240 7166M
94241 7166M
94242 7166M
94243 7166M
94244 7166M
94245 7166M
94246 7166M
94247 7166M
94248 7166M
94249 7166M
94250 7166M
94251 7166M
94252 7166M
94253 7166M
94254 7166M
94255 7166M
94256 7166M
94257 7166M
94258 7166M
94259 7166M
94260 7166M
94261 7166M
94262 7166M
94263 7166M
94264 7166M
94265 7166M
94266 7166M
94267 7166M
94268 7166M
94269 7166M
94270 7166M
94271 7166M
94272 7166M
94273 7166M
94274 7166M
94275 7166M
94276 7166M
94277 7166M
94278 7166M
94279 7166M
94280 7166M
94281 7166M
94282 7166M
94283 7166M
94284 7166M
94285 7166M
94286 7166M
94287 7166M
94288 7166M
94289 7166M
94290 7166M
94291 7166M
94292 7166M
94293 7166M
94294 7166M
94295 7166M
94296 7166M
94297 7166M
94298 7166M
94299 7166M
94300 7166M
94301 7166M
94302 7166M
94303 7166M
94304 7166M
94305 7166M
94306 7166M
94307 7166M
94308 7166M
94309 7166M
94310 7166M