I have Magento 1.9. When I try to add around 150 items to a bundled product, I'm getting the following error message:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (rockford_magrock.catalog_product_bundle_selection, CONSTRAINT FK_CAT_PRD_BNDL_SELECTION_PRD_ID_CAT_PRD_ENTT_ENTT_ID FOREIGN KEY (product_id) REFERENCES catalog_product_entity (`entit)

The funny thing is, when I just add a few at a time, this works.

Is there some memory limit or some PHP variable I am hitting that may be causing this error?

These are all just simple products I am adding to the bundle with an attribute type = "default".

I'm also getting this error in the error log:

ERR (3): Notice: Undefined index: delete in /home/rockfordjchhh/public_html/app/code/core/Mage/Bundle/Model/Product/Type.php on line 320

  • Today I have faced with the similar issue. I will debug it now, and will let you know about the result. May 11, 2015 at 20:16

4 Answers 4


This is a really tricky case. If you want to use many bundle items (for example about 100 per one option), you should increase the value of php setting max_input_vars (default value is 1000).

Because Magento creates a lot of HTML inputs for each bundle item, and when browser posts the data to server, php will ignore some POST fields, if there were more than 1000 variables in request.


There is a code fault in core magento


find function getSelectionsCollection

public function getSelectionsCollection($optionIds, $product = null)
        $keyOptionIds = (is_array($optionIds) ? implode('_', $optionIds) : '');
        $key = $this->_keySelectionsCollection . $keyOptionIds;

replace it with

public function getSelectionsCollection($optionIds, $product = null)
        if(empty($optionIds)) $optionIds = array(1);
        $keyOptionIds = (is_array($optionIds) ? implode('_', $optionIds) : '');
        $key = $this->_keySelectionsCollection . $keyOptionIds;

I've written an article about this here http://magenote.com/php-max_input_vars-bundle-product-nightmare/

Starting in php 5.3.9 a new setting was added: max_input_vars.  The main purpose of Max Input Vars is to help mitigate the possibility of denial of service attacks which use hash collisions.  Whether you know what that means or not doesn’t matter.   But if you are using Magento and have recently upgraded to a php version, and suddenly you have some products (especially bundle products with a lot of options)  not saving, this is likely your culprit.  We have also seen reports of this affecting users with a large amount of categories not saving.  In our case we have bundle products with up to 24 options, and with each option having up to 60 choices each.  When we would try to save data, it will not save with the default setting of max_input_vars=1000.   We had to increase this number drastically in our php.ini file for the saving to begin working again.   If you have root or sudo access you can do this yourself, otherwise you will need to contact your hosting provider.

Default Value:

max_input_vars = 1000

New Example Increased Value:

max_input_vars = 10000


If your host uses Suhosin for added security there are 2 more setting that will need to be increased as well.   Further, you may be an older version and experience these symptoms just because of these two Suhosin settings.  In either case these 2 values will need increased, and if using php 5.3.9 increase max_input_vars as well.

Example Default Values:

suhosin.request.max_vars = 1000

suhosin.post.max_vars = 1000

New Example Increased Values:

suhosin.request.max_vars = 10000

suhosin.post.max_vars = 10000


you have change in php.ini file max_input_vars = 1000 to max_input_vars = 10000 after add bundle items, it is working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.