Magento:订单后无法将产品添加到购物车

发布于 2024-12-19 10:24:47 字数 1100 浏览 1 评论 0原文

下订单后,无法将产品添加到购物车。 Magento 不断告诉我:无法将商品添加到购物车。

另外,如果我尝试重新订购,则会收到错误:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1";i:1;s:2954:"#0 C:\wamp\www\ronamagento\trunk\lib\Zend\Db\Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)

如果我注销然后重新登录,则一切正常,直到我下另一个订单。

有什么想法吗?

---------------------- 编辑 -------------------------- < br>
错误似乎来自 sales/order/controllers/OrderController.php ,位于 $cart->save(); 的重新排序函数中。
在 Checkout/controllers/CartController.php 中的添加函数中使用相同的代码
似乎我的购物车对象已损坏或发生其他情况。

---------------------- 编辑 --------------------- -----

---------------------- 编辑 #2 -------------------- ------

好吧,如果我注释掉 $this->getQuote()->collectTotals(); 行在 Checkout/model/cart.php 的保存功能中,它似乎可以工作,但没有显示该商品已添加到我的购物车。然后我放回代码行,一切正常。似乎collectTotals() 中有问题......

---------------------- 编辑#2 ------------------- - - - -

谢谢!

After placing an order, it is not possible to add a product to cart. Magento keeps telling me : Cannot add the item to shopping cart.

Plus, if I try to reorder , I got an error :

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1";i:1;s:2954:"#0 C:\wamp\www\ronamagento\trunk\lib\Zend\Db\Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)

If I log out then relog in, everything works fine until I place another order.

Any idea?

---------------------- EDIT --------------------------

The errors seems to come from sales/order/controllers/OrderController.php , in the reorder function at the $cart->save();

And the same code in Checkout/controllers/CartController.php in the add function
Seems like my cart object is broken or something.

---------------------- EDIT --------------------------

---------------------- EDIT #2 --------------------------

Well , if I comment the line $this->getQuote()->collectTotals(); in the save function of Checkout/model/cart.php it seems to work but doesn't show that the item has been added to my cart. Then I put back the line of code and everything works fine. Seems like something is wrong in collectTotals()...

---------------------- EDIT #2 --------------------------

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷荒 2024-12-26 10:24:47

这很可能是由第 3 方模块引起的问题,可能重写 Magento 模型或提供事件侦听器(我的首选猜测),其中包含一些未转义的(可能是直接的,不使用 Magento ORM 基础设施)SQL 查询。

作为快速调试,我建议您尝试禁用(不是通过管理员,这不起作用,因为它只是脱离渲染,而不是重写或事件侦听器,而是通过重命名第三方模块的“app/etc/modules/[Module_Name ].xml”文件到类似“app/etc/modules/[Module_Name].xml.disabled”这样Magento会忽略它)您拥有的每个第3方模块 - 一个接一个- 直到您可以下订单。

一旦确定了负责的模块,您可以通过正确转义 SQL 查询中的字符串来找到修复程序,或者返回模块制造商要求为您提供修复程序。

您还可以尝试使用 xdebug 进行正确的调试,我强烈建议不要在生产环境中执行任何这些操作,因为可能会导致中断。

请注意,使用带有未转义值的原始 SQL 查询是一种安全威胁,因为它可能会导致 SQL 注入攻击。只要人们在您的网站上使用精心设计的 URL,您的客户数据就很容易被盗,或者您的数据库被黑客入侵。

This most likely is an issue caused by a 3rd party module, perhaps rewriting a Magento model or providing an event listener (my preferred guess) with some unescaped (perhaps direct, not using Magento ORM infrastructure) SQL queries in it.

As a quick debug, I would suggest you try disabling (not via Admin, that wouldn't work as it does just disengage rendering, not rewrites or event listeners, but via renaming the third party module's "app/etc/modules/[Module_Name].xml" file to something like "app/etc/modules/[Module_Name].xml.disabled" so Magento ignores it) each of the 3rd party modules you have - one by one - until you can place the order.

Once you have identified the responsible module, you can either find the fix by properly escaping the string in the SQL query, or get back to the module's manufacturer asking to provide a fix for you.

You can also try proper debugging using xdebug, and I would highly discourage doing any of these in production environment, as you may cause outage.

Please note that using raw SQL queries with unescaped values is a security threat, as it may lead to SQL injection attacks. You could easily get your customer data stolen, or your database hacked, just by people using properly crafted URLs on your site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文