Magento Custom Options - saving new values doesn't work

http://stackoverflow.com/questions/13122738/magento-custom-options-saving-new-values-doesnt-work

I ran into a problem using the custom options in Magento.For various products, I am using custom options with over 100 values (drop-down).

The problem is that at a certain point, option values won't be saved anymore. When clicking the save button, a succes confirmation shows up but the new added values are gone.

I already observed the ajax post request when saving the options and found that the new values were listed in the post paramaters, so the problem apparently is not in the javascript.

I'm trying to localize the problem but I don't know where the actual saving of the custom options takes place. Does anyone know the filename/location/function ?

Or better, does anyone knows what is going wrong here?

I would hesitate to guess that you've now got so many custom options that the form being POSTed has blown through the number of allowed input_vars allowed in your php.ini

Put this in your php.ini

; http://www.php.net/manual/en/info.configuration.php#ini.max-input-varsmax_input_vars = 2000

Reboot Apache and try again.

php.ini 文件里的  max_input_vars 默认值为 1000, 正常情况下够用,偶尔遇到我这种提交2000多个表单的情况还是比较少见的,不过,如果发现提交表单个数不全的情况,可以试试修改这个配置。

用 phpinfo()查看。

php.ini 里没有max_input_vars 一项,可以增加这一项然后赋值


另外可以参考

http://www.th7.cn/Program/php/201409/275051.shtml

在某个项目中,每次提交都丢了部分数据,觉得非常奇怪,开始的时候以为是数据量过大,但后来又觉得不应该,因为如果是数据量过大,要么就是提交失败,要么就是直接报错啊?

但事实上我每次提交都是成功的,但print_r($_POST)的时候,总丢了不少的数据,这是为什么呢?

于是,将http头中的form内容全部copy出来,查看了一下,发现共是1200多行。打印POST的时候,只有1000行,咦,这不科学啊?少了200多行?

google了一下,原来,PHP有这么一个配置:

XML/HTML代码
  1. ; How many GET/POST/COOKIE input variables may be accepted  
  2. ; max_input_vars = 1000  

而它的默认值 是1000,好吧,如果不是这次意外,根本不会发现项目中存在的这个BUG,毕竟要提交1000多个参数还是有难度的。顺便说一下:param[]=1&param[]=2是属于两个参数。所以如果你提交的项目中有多个数组,每个数组又有不少值的话,你就真的要小心了

手贱,将max_input_vars 改成5000,问题解决。。

------

回顾,这种因为偷懒的事情往往出现在哪里呢?

1、ajax提交,不管三七二十一,将某堆数据 serializeArray(),jquery的这个功能,偶尔真心会让人吃药。

2、日程管理和广告排期管理,这时候input的key确实 有可能会超过1000,但我还是建议先序列化再存到一个字段提交更安心 吧?


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值