Opencart 代码错误
当我的客户尝试更新 opencart 1.4.9.3 中的产品时,我收到此错误:
2011-08-06 13:54:29 - PHP Notice: Undefined index: quantity in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
2011-08-06 13:54:29 - PHP Notice: Undefined index: subtract in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
2011-08-06 13:54:29 - PHP Notice: Undefined index: price in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
2011-08-06 13:54:29 - PHP Notice: Undefined index: price_full in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
2011-08-06 13:54:29 - PHP Notice: Undefined index: prefix in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
这是模型文件: http://pastebin.com/VHL4BTLN
这是控制器文件: http://pastebin.com/GT6YsFqt
我知道表单项正在通过控制器进入模型,但是它不会将所有选项信息保存到数据库中。
I am getting this error when my client tries to update a product in opencart 1.4.9.3:
2011-08-06 13:54:29 - PHP Notice: Undefined index: quantity in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
2011-08-06 13:54:29 - PHP Notice: Undefined index: subtract in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
2011-08-06 13:54:29 - PHP Notice: Undefined index: price in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
2011-08-06 13:54:29 - PHP Notice: Undefined index: price_full in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
2011-08-06 13:54:29 - PHP Notice: Undefined index: prefix in /home/adesignlink/innovativetrailers4less.com/admin/model/catalog/product.php on line 198
Here is the model file:
http://pastebin.com/VHL4BTLN
Here is the controller file:
http://pastebin.com/GT6YsFqt
I know that the form items ARE getting through the controller and into the model but it is not saving all the option info into the db.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这两个类都没有问题!这就是正在发生的事情。
您的控制器从 Model 类调用 editProduct 方法,并传递来自模板页面的产品 ID 和 POST 数据。 Controller 类中的第 81 行:
因此,无论问题是什么,都与您的 POST 请求有关。
所有错误消息都来自该行中的 $product_option_value,它是 $product_option['product_option_value'] 的子数组,$product_option 来自 $data['product_option'],即 $this->request->post。
检查您的模板并查看是否正确传递了产品选项。我建议您在服务器上安装 Xdebug 并尝试调试代码。只需对控制器的 81 等进行中断并检查值即可。
There is nothing wrong with neither of these two classes ! Here is what's happening.
Your controller calls the editProduct method from your Model class and passes the product id and POST data that comes from your template page. Line 81 in your Controller class:
So whatever the problem is, has something to do with your POST request.
All the error messages are coming from $product_option_value in that line which is a subarray of $product_option['product_option_value'], and $product_option comes from $data['product_option'] which is $this->request->post.
Check your template and see if you are passing the product options correctly. I suggest you to install Xdebug on your server and try to debug the code. simply put a break on like 81 of your controller and check the values.