prestashop-1.7 - 在 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 查询中,然后按字母顺序获取状态。
此致
推荐阅读
- javascript - 输入搜索在 JS 中被阻止
- java - 逆时针旋转矩阵 M*N 的每个环
- python - 在一秒钟内打印 40 条消息。打印件必须在一秒钟内均匀分布
- docker - 无法在 Windows 10 上的本地 Docker 中使用弹性搜索
- iteration - 遍历列表列表,每个列表包含 2 个项目
- ruby - 如何引发异常,将其作为参数发送给另一个方法,并在另一个方法中挽救异常?
- iframe - 使用 Svelte 访问 iframe 内容
- mysql - 在 SSMS 中创建链接服务器到远程服务器上的 MySQL 数据库
- css - 图标显示为正方形而不是图标图像
- javascript - 如何给一个人定型
- 与所有人相反
- 在反应?