SELECT 
  pf.feature_id, 
  pf.feature_style, 
  pf.position, 
  pf.purpose, 
  pf.display_on_catalog, 
  pfd.description, 
  pfd.internal_name, 
  pfd.prefix, 
  pfd.suffix, 
  (
    CASE WHEN pf.purpose = 'group_catalog_item' THEN 0 ELSE 1 END
  ) AS purpose_position 
FROM 
  cscart_product_features AS pf 
  INNER JOIN cscart_product_features_descriptions AS pfd ON pf.feature_id = pfd.feature_id 
  AND pfd.lang_code = 'en' 
WHERE 
  pf.feature_id IN (
    22702, 20545, 23110, 19927, 21147, 21328, 
    21150, 20543, 21144, 21329, 21148, 
    19929, 21152
  ) 
ORDER BY 
  purpose_position ASC, 
  pf.position ASC, 
  pf.feature_id ASC

Query time 0.00266

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "read_sorted_file": {
          "filesort": {
            "sort_key": "case when pf.purpose = 'group_catalog_item' then 0 else 1 end, pf.position, pf.feature_id",
            "table": {
              "table_name": "pf",
              "access_type": "range",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["feature_id"],
              "rows": 13,
              "filtered": 100,
              "index_condition": "pf.feature_id in (22702,20545,23110,19927,21147,21328,21150,20543,21144,21329,21148,19929,21152)"
            }
          }
        }
      },
      {
        "table": {
          "table_name": "pfd",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "9",
          "used_key_parts": ["feature_id", "lang_code"],
          "ref": ["dev_db.pf.feature_id", "const"],
          "rows": 1,
          "filtered": 100,
          "index_condition": "pfd.lang_code = 'en'"
        }
      }
    ]
  }
}

Result

feature_id feature_style position purpose display_on_catalog description internal_name prefix suffix purpose_position
22702 dropdown_labels 0 group_catalog_item N Tùy chọn Tùy chọn 0
19927 dropdown_labels 0 group_variation_catalog_item N Option Option 1
19929 dropdown_labels 0 group_variation_catalog_item N Option Option 1
20543 dropdown_labels 0 group_variation_catalog_item N Choose fragrance Choose fragrance 1
20545 dropdown_labels 0 group_variation_catalog_item N Choose the scented candle Choose the scented candle 1
21144 dropdown_labels 0 group_variation_catalog_item N Choose fragrance Choose fragrance 1
21147 dropdown_labels 0 group_variation_catalog_item N Option Option 1
21148 dropdown_labels 0 group_variation_catalog_item N Option Option 1
21150 dropdown_labels 0 group_variation_catalog_item N Option Option 1
21152 dropdown_labels 0 group_variation_catalog_item N Option Option 1
21328 dropdown_labels 0 group_variation_catalog_item N Choose fragrance Choose fragrance 1
21329 dropdown_labels 0 group_variation_catalog_item N Choose scent Choose scent 1
23110 dropdown_labels 0 group_variation_catalog_item N Choose scent 1 Choose scent 1 1