magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

2.1.0 Updating Grouped product with 100 grouped products gives error Undefined index: position

Open Crossmotion opened this issue 10 years ago • 4 comments

Preconditions

Magento 2.0.1

Steps to reproduce

  1. Add Grouped product by code via the \Magento\Catalog\Api\ProductRepositoryInterface
  2. Add +/- 100 Simple products (my last test had 97 products) via the \Magento\Catalog\Api\ProductRepositoryInterface
  3. Add the Simple products to the Grouped product (In my case I did it by adding a record to the catalog_product_link table: //Create new link $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // instance of object manager $q = $objectManager->get('\Magento\Framework\App\ResourceConnection'); $result = $q->getConnection('core_write')->query("insert into catalog_product_link (linked_product_id, product_id,link_type_id) values (".$linked_product_id.",".$product_id.",".$link_type_id.")");

I know this is not the correct way but I could not find a better solution yet....

  1. Open the product via Admin
  2. Save the product

Expected result

You saved the product notice

Actual result

Notice: Undefined index: position in /home/www/crossmotion/mag2.crossmotion.nl/www/vendor/magento/module-grouped-product/Model/Product/Initialization/Helper/ProductLinks/Plugin/Grouped.php on line 99

And the product is not saved.

I have not tested it by manually inserting products since 100 products is a bit much to add. I dit also try it with products with less grouped products. but the problem seems to occur somewhere around 80 - 100.

I am running the Magento 2.1.0 stable from Composer on PHP 7.0.7

UPDATE: While writing this and testing I noticed that when I refresh the product after trying and then saving it again, it does save... so the problem only occurs the first time you try it...

Crossmotion avatar Jul 04 '16 13:07 Crossmotion

UPDATE: I have a product with 180 grouped products now. the problem is permanent now, it does not go away the second time you try...

Crossmotion avatar Jul 15 '16 08:07 Crossmotion

We just ran into this issue recently so for anyone else who might run into it, the problem comes from the "position" being empty when it is inserted into the DB. When it renders the associated products on the page, the JS only fills in the position for the currently visible page causing anything on page 2+ to send no position value in the POST request and thus trigger this error.

Easiest solution we found is to go down to the Grouped Products section and click the next page button for all the pages you have: 0rdjjuk

This will cause them all to render onto the page and the JS will attach their respective position value and then you can save the product successfully. Once the product saves with all the corrected position values it should no longer error on future saves since it will pre-populate the form with the now saved values.

marshallthornton avatar Dec 02 '17 05:12 marshallthornton

@Crossmotion, thank you for your report. We've created internal ticket(s) MAGETWO-85181 to track progress on the issue.

magento-engcom-team avatar Dec 07 '17 10:12 magento-engcom-team

@Crossmotion, thank you for your report.

Unfortunately, we are archiving this ticket now as it did not get much attention from both Magento Community and Core developers for an extended period. This is done in an effort to create a quality, community-driven backlog which will allow us to allocate the required attention more easily.

You may learn more about this initiative following this link.

Please feel free to comment or reopen the ticket if you think it should be reviewed once more. Thank you for collaboration.

magento-engcom-team avatar May 08 '18 14:05 magento-engcom-team