SELECT 
  p.product_id, 
  COUNT(fv_current.feature_id) AS matching_features_count, 
  IF(p.brand_id = 0, 1, 0) AS brand_match 
FROM 
  cscart_products AS p 
  JOIN cscart_products_categories AS pc ON pc.product_id = p.product_id 
  LEFT JOIN cscart_product_features_values AS fv ON fv.product_id = p.product_id 
  AND fv.feature_id IN (
    744, 737, 741, 805, 807, 747, 796, 775
  ) 
  LEFT JOIN cscart_product_features_values AS fv_current ON fv.feature_id = fv_current.feature_id 
  AND fv.variant_id = fv_current.variant_id 
  AND fv_current.product_id = 21422 
WHERE 
  p.status = 'A' 
  AND p.product_id != 21422 
  AND pc.category_id = 712 
GROUP BY 
  p.product_id 
ORDER BY 
  matching_features_count DESC, 
  brand_match DESC, 
  p.product_id 
LIMIT 
  5

Query time 0.00187

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "39.95"
    },
    "ordering_operation": {
      "using_filesort": true,
      "grouping_operation": {
        "using_temporary_table": true,
        "using_filesort": false,
        "nested_loop": [
          {
            "table": {
              "table_name": "pc",
              "access_type": "range",
              "possible_keys": [
                "PRIMARY",
                "pt",
                "idx_pc_product_id_type"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id",
                "product_id"
              ],
              "key_length": "6",
              "rows_examined_per_scan": 38,
              "rows_produced_per_join": 38,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "4.41",
                "eval_cost": "3.80",
                "prefix_cost": "8.21",
                "data_read_per_join": "608"
              },
              "used_columns": [
                "product_id",
                "category_id"
              ],
              "attached_condition": "((`dev2`.`pc`.`category_id` = 712) and (`dev2`.`pc`.`product_id` <> 21422))"
            }
          },
          {
            "table": {
              "table_name": "p",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "age_verification",
                "status",
                "idx_parent_product_id",
                "cscart_products_brand_id_index",
                "cscart_products_conditions_index",
                "cscart_products_real_company_id_index",
                "cscart_products_product_id_index",
                "idx_status"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "dev2.pc.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 3,
              "filtered": "10.00",
              "cost_info": {
                "read_cost": "9.50",
                "eval_cost": "0.38",
                "prefix_cost": "21.51",
                "data_read_per_join": "28K"
              },
              "used_columns": [
                "product_id",
                "status",
                "brand_id"
              ],
              "attached_condition": "(`dev2`.`p`.`status` = 'A')"
            }
          },
          {
            "table": {
              "table_name": "fv",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "fl",
                "product_id",
                "fpl",
                "idx_product_feature_variant_id"
              ],
              "key": "product_id",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "dev2.pc.product_id"
              ],
              "rows_examined_per_scan": 6,
              "rows_produced_per_join": 23,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "1.95",
                "eval_cost": "2.33",
                "prefix_cost": "25.79",
                "data_read_per_join": "17K"
              },
              "used_columns": [
                "feature_id",
                "product_id",
                "variant_id",
                "lang_code"
              ],
              "attached_condition": "<if>(is_not_null_compl(fv), (`dev2`.`fv`.`feature_id` in (744,737,741,805,807,747,796,775)), true)"
            }
          },
          {
            "table": {
              "table_name": "fv_current",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "fl",
                "variant_id",
                "product_id",
                "fpl",
                "idx_product_feature_variant_id"
              ],
              "key": "product_id",
              "used_key_parts": [
                "product_id",
                "feature_id",
                "variant_id"
              ],
              "key_length": "9",
              "ref": [
                "const",
                "dev2.fv.feature_id",
                "dev2.fv.variant_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 23,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "11.83",
                "eval_cost": "2.33",
                "prefix_cost": "39.95",
                "data_read_per_join": "17K"
              },
              "used_columns": [
                "feature_id",
                "product_id",
                "variant_id",
                "lang_code"
              ]
            }
          }
        ]
      }
    }
  }
}

Result

product_id matching_features_count brand_match
9184 0 0
14253 0 0
14714 0 0
18006 0 0
20475 0 0