简体   繁体   English

Prestashop模块调试

[英]Prestashop module debugging

I am newbie in Prestashop module development so sorry if it is a fool question... I have been reading the docs but I haven't found what I am looking for so here I go, 我是Prestashop模块开发的新手,所以很抱歉,如果这是一个愚蠢的问题...我一直在阅读文档,但没有找到我想要的东西,所以我去了,

I'd like to show a message on the screen (just for debugging purpose) with different context vars and so forth when actionCartSave. 我想在屏幕上显示一条消息(仅用于调试目的),并带有不同的上下文变量,以此类推。 Something similar to "console.log()" or "alert()" in js. 类似于js中的“ console.log()”或“ alert()”。

Impossible to add the product to the cart. 无法将产品添加到购物车。

textStatus: 'parsererror' textStatus:“ parsererror”

errorThrown: 'SyntaxError: JSON Parse error: Unrecognized token '<'' errorThrown:'SyntaxError:JSON解析错误:无法识别的令牌'<''

responseText: responseText的:

< xmp style="text-align: left;" <xmp style =“ text-align:left;” > message: < /xmp> >消息:</ xmp>

*{ * {

"products" : [...] * “产品” :[...] *

I have already test this code: 我已经测试了这段代码:

public function hookActionCartSave( $params )
{
     ppp('message: ');
     return true;
}

...inside the module class definition but I am getting this error when I add a product to the cart: ...在模块类定义中,但是将产品添加到购物车时出现此错误:

I get this text in a different browser window. 我在另一个浏览器窗口中获得了此文本。

So please, what is the best way to go? 那么,请问最好的方法是什么?

Hope everything is clear. 希望一切都清楚。 Thanks. 谢谢。

What you have done is correct, this error message is something thrown by javascript running in your browser since the additional information you are printing out using ppp isn't valid JSON. 您所做的是正确的,此错误消息是浏览器中运行的javascript抛出的错误消息,因为使用ppp打印出的其他信息不是有效的JSON。

If you use Chrome, use developer tools and select the Network tab. 如果您使用的是Chrome,请使用开发者工具,然后选择“网络”标签。 You will see the ajax call here. 您将在此处看到ajax调用。 You can inspect this call in more detail by clicking on it. 您可以通过单击来更详细地检查此呼叫。

不确定这是最佳选择,但我发现使用简单的调试工具很有用

throw new Exception('Custom message ' . $someVariable);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM