【发布时间】:2019-03-05 22:56:40
【问题描述】:
我是 Prestashop 的新手,我正在尝试添加一个新的“排序依据”字段(默认情况下,您有:“相关性”、“名称,A 到 Z”、“名称,Z 到 A”、“价格,从低到高”,“价格,从高到低”)
如你们所知,该功能位于名为: “Ps_facetedsearch”,链接here。
我试过了:
- 编辑模块文件,这可行,但如果我想保留该功能,我无法再升级模块。
- 覆盖,但似乎无法使其工作,它仍然使用相同的旧模块,而不是被覆盖的模块。
所以我的问题是:
- 如何以最优雅/最简单的方式在产品列表(前面)中添加额外的“排序依据”字段?我很想听听解决此问题的任何其他方法。
- 如果您购买了另一个覆盖主模块的模块(“Ps_facetedsearch”,这样两个覆盖不会发生冲突),您能否在不使用覆盖的情况下执行此操作
感谢任何提示!!!
PrestaShop 版本:1.7.4.2
为了添加额外的“排序依据”字段,我需要复制/粘贴 Ps_facetedsearch 模块中的行:
private function getAvailableSortOrders()
{
return [
(new SortOrder('product', 'position', 'asc'))->setLabel(
$this->module->getTranslator()->trans('Relevance', array(), 'Modules.Facetedsearch.Shop')
),
(new SortOrder('product', 'name', 'asc'))->setLabel(
$this->module->getTranslator()->trans('Name, A to Z', array(), 'Shop.Theme.Catalog')
),
(new SortOrder('product', 'name', 'desc'))->setLabel(
$this->module->getTranslator()->trans('Name, Z to A', array(), 'Shop.Theme.Catalog')
),
(new SortOrder('product', 'price', 'asc'))->setLabel(
$this->module->getTranslator()->trans('Price, low to high', array(), 'Shop.Theme.Catalog')
),
(new SortOrder('product', 'price', 'desc'))->setLabel(
$this->module->getTranslator()->trans('Price, high to low', array(), 'Shop.Theme.Catalog')
)
// copy and paste here for another one, but lose the upgradability
// of a module.
];
}
在 Ps_FacetedsearchProductSearchProvider.php 中找到 (第 117-136 行)
【问题讨论】:
-
可能可以在覆盖的帮助下完成
标签: php symfony model-view-controller prestashop prestashop-1.7