prestashop-1.7 - 如何从后台调用模块方法,特别是从订单页面
问题描述
我在 Prestashop 1.7 中创建了一个模块
我想从后台订单页面调用模块方法。
我正在覆盖订单页面视图以创建 url。
URL格式应该是什么
到目前为止我已经尝试过:
{url entity='module' name='mymodule' controller='mymodulecontroller' params=['order_id' => $order->id]}
它提供了如下链接:
http://localhost/ps17/module/mymodule/mymodulecontroller?order_id=4
我想在调用此方法时返回一个值。
不想给 JS 分配任何东西。
该模块没有配置页面。
有人可以阐明一下吗?我知道我的问题不是很清楚。我可以澄清你的问题。
我只有这些文件 MyModule.php Controller/Admin/MymoduleController.php Override/.......
模块被安装。覆盖不起作用,必须手动覆盖。挑战是使用 url 调用 MyModule.php 或 Controller/Admin/MymoduleController.php 的方法。
谢谢你!
解决方案
Prestashop 有很多 Hooks。你必须在你的模块中使用它们,也不需要任何覆盖。
1- 在安装过程中在一些 Hooks 中注册你的模块
$this->registerHook('displayAdminOrder')
2- 在模块的 Hook 方法中运行代码
public function HookDisplayAdminOrder($params)
{
// some of the codes to display something in display Hooks
// Or some of the codes to do something in action Hooks
}
管理订单页面中的一些重要 Hooks:
- actionOrderStatusPostUpdate
- displayAdminOrder
- displayAdminOrderTabContent
- displayAdminOrderContentOrder
- displayAdminOrderContentShip
- displayAdminOrderLeft
- displayAdminOrderRight 完整列表:Hooks PS1.7 列表
推荐阅读
- java - 通过 maven 运行 scalatest 时出现“java.lang.ClassCastException”错误
- javascript - 我将如何正确地 .catch 这个?
- visual-studio - 通过 `dotnet add package ..` 处理 nugets 与通过 Visual Studio UI 添加 nugets 的区别
- c# - Xamarin 表单编辑器属性
- firebase - 无法从“index.cjs.js”中找到模块“firebase-admin”
- ios - 在 1 个集合视图中选择单元格以更改第二个集合视图属性(Xcode)
- python - Python:从 ctypes 外部函数成功返回后内存损坏
- terraform - Terraform:如何将 Windows 工作节点添加到 eks 集群?
- webmethods - 如何使用 WebMethods 检查字符串是否为回文
- html - 更改按钮的字体