在 Prestashop 1.7 中按字母顺序排列状态 [英] Order States aphabetically in Prestashop 1.7

查看:71
本文介绍了在 Prestashop 1.7 中按字母顺序排列状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Does anyone know how can you order alphabetically states when you are editing o creating a new customer address.

提前致谢

推荐答案

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

I finally solved it by overriding the file State.php

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

Just create a new file inside /overrides/classes/State.php and paste this code:

<?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 查询中,然后按字母顺序获取状态.

It just adds ORDER BY name ASC' to the SQL query, then it gets the states ordered alphabetically.

最好的问候

这篇关于在 Prestashop 1.7 中按字母顺序排列状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆