如何解决如何将安装错误返回给Prestashop 1.7中的模块管理器?
我正在尝试调试我的模块安装,在某些情况下它会根据某些字段返回false。根据哪个失败,我想显示输出。我尝试过:
\Tools::displayError('This worked.');
array_push($this->context->controller->errors,$this->l('This worked.'));
我的安装如下:
public function install() {
\Tools::displayError('This worked.');
array_push($this->context->controller->errors,$this->l('This worked.'));
return (parent::install() && false); // Force a fail to test
}
但是,我似乎得到的是:
Unfortunately,the module did not return additional details.
我在互联网上寻找修复程序,但have only come across outdated ones。任何帮助将不胜感激。
编辑:我的构造函数的Need_instance设置为1:
public function __construct() {
...
$this->need_instance = 1;
...
parent::__construct();
...
}
更新:为了帮助将来的查看者,insert
类的Db
函数会自动在表名中添加前缀。删除self::DB_PREFIX
可以解决此问题。
return \Db::getInstance()->insert('iezon_portfolio',array(
'img_link' => pSQL($img),'title' => pSQL($title),'description' => pSQL($description),'company_name' => pSQL($company),'company_url' => pSQL($company_url),'testimonial' => pSQL($testimonial),'is_favourite' => (int) $fav,));
解决方法
尝试这样的事情:
public function install()
{
if ($this->checkForErrors()) {
$this->_errors[] = $this->l('Error message');
return false;
}
...rest of the code...
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。