在 Prestashop 1.7 中按字母顺序排列状态

Order States aphabetically in Prestashop 1.7

有谁知道在编辑或创建新客户地址时如何按字母顺序排列各州。

提前致谢

我终于通过覆盖文件解决了它State.php

只需在 /overrides/classes/State.php 中创建一个新文件并粘贴此代码:

<?php class State extends StateCore {
/**
 * Get states by Country ID.
 *
 * @param int $idCountry Country ID
 * @param bool $active true if the state must be active
 *
 * @return array|false|mysqli_result|PDOStatement|resource|null
 */

    public static function getStatesByIdCountry($idCountry, $active = false)
    {
        if (empty($idCountry)) {
            die(Tools::displayError());
        }
        return Db::getInstance()->executeS(
            'SELECT *
            FROM `' . _DB_PREFIX_ . 'state` s
            WHERE s.`id_country` = ' . (int) $idCountry . ($active ? ' AND s.active = 1' : '') . '
            ORDER BY `name` ASC'
        );
    }
}

它只是将 ORDER BY name ASC' 添加到 SQL 查询中,然后它获得按字母顺序排列的状态。

此致