magento-engcom / import-export-improvements

Open Software License 3.0
31 stars 29 forks source link

Imported bundle products are not assigned stock status #80

Closed piotrekkaminski closed 5 years ago

piotrekkaminski commented 6 years ago

From @indefinitedevil on November 17, 2017 13:2

When importing a new bundle product (can be entirely new, or generated through replacement), no entry is generated for it in cataloginventory_stock_status. This means that when the frontend tries to display it, it encounters a NULL entry when trying to discover whether the product is salable.

vendor/magento/module-catalog/Model/Product/Type/AbstractType.php line 355 When running getData('is_salable'), this returns NULL because the cataloginventory_stock_status row doesn't exist. Because it returns NULL, the isSalable function returns false, and that means that the bundle product does not appear in category lists and shows as out of stock on the frontend.

Reindexing does not resolve issue, and neither does saving the product in the backend.

Preconditions

  1. Magento Commerce 2.2.0
  2. PHP 7.0.23 / 7.1.11 (tested on two servers)
  3. MySQL 5.6.37 / MariaDB 10.2.7

Steps to reproduce

  1. Create bundle product that shows on frontend as in stock
  2. Export bundle product
  3. Either: 3.a) change the SKU of the bundle product and import it 3.b) re-import it in Replace mode

Expected result

  1. New/replaced product shows as in stock

Actual result

  1. New/replaced product shows as out of stock

Copied from original issue: magento/magento2#12330

piotrekkaminski commented 6 years ago

From @indefinitedevil on November 17, 2017 16:27

Addendum: this also happens when you add customisable options or change whether they are required.

piotrekkaminski commented 6 years ago

From @jwgraves2 on November 18, 2017 17:20

We are experiencing the same with the same configuration/stack and steps to reproduce.

piotrekkaminski commented 6 years ago

From @magento-engcom-team on November 20, 2017 9:23

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

piotrekkaminski commented 6 years ago

From @tonybrown85 on December 8, 2017 15:28

@magento-engcom-team Any ETA on this please guys? Our client's website has around 80% of it's products as Bundles. They are on M2.1.5 which is extremely broken and we're trying to get them upgraded to 2.2 but this is a massive show stopper. Please provide an update or temporary fix. Thank you, Tony.

piotrekkaminski commented 6 years ago

From @ben-pushlogic on December 8, 2017 15:50

@magento-engcom-team - This is also an issue for me. After upgrading from M2.1.5 bundles no longer display. Same process listed by @indefinitedevil Is this likley to be fixed soon? Thanks Ben

piotrekkaminski commented 6 years ago

From @tonybrown85 on December 12, 2017 13:24

@magento-engcom-team Is anybody going to get back to us re. this please? We cannot launch our clients website without this working so this is causing us a huge amount of problems! Any workaround at this point would be massively appreciated just to get the bundle products appearing. Thanks, Tony

piotrekkaminski commented 6 years ago

From @PieterCappelle on December 21, 2017 21:35

Can you assign this to me? I’ll fix it. Please add import/export label. Thanks!

piotrekkaminski commented 6 years ago

From @jwgraves2 on December 22, 2017 1:2

Glad to see this on the way to resolution. For anyone waiting on a fix, what worked for us was: 1) import the simples on which your bundles are based; 2) import the bundles via csv; 3) note the stock status on the bundles is out of stock (the bug); 4) create a dummy simple called "AAA" with inventory zero; 5) For each bundle product, add the AAA simple to the bundle values and save it out; 6) Note the stock status is in-stock and since there is zero inventory of AAA, that option does not display; ("AAA" we used for easy sorting by name when adding the simple to the bundle). Not a very elegant solution, but it kept our project going.

mangoextensions commented 6 years ago

The M2 import function does not seem to insert the parent/child pairs to the table catalog_product_relation

A quick fix, using mysql and then reindexing, so the parent/child relations are added to the table:

insert into catalog_product_relation(parent_id, child_id) select parent_product_id , product_id from catalog_product_bundle_selection where parent_product_id not in ( select distinct parent_id from catalog_product_relation )

ladle3000 commented 6 years ago

@mngtestuser do you have to do this association for every child product in the bundle? We have hundreds of options.

mangoextensions commented 6 years ago

@snoroozi : the mysql query has to be run after the import is ready and will add all the associations for all bundle products. In our case, for A bundle products, B select options for each product and C options for each select, AxBxC records were added.

ladle3000 commented 6 years ago

@mngtestuser thank you. Unfortunately this is not working for me, because I think the parent id has multiple entries in my case, since we use the same child for multiple options.

Do you know how I could rework the query in this case?

ladle3000 commented 6 years ago

Further, does anyone know where to set sort order in magento 2 for the bundle option sets? I see no place in the csv export that specifies this.

adam-paterson commented 6 years ago

@dmanners Self-assigned this for the next phase of work. Two of the above comments are from a founder of my agency and the founder of a freelance project. I've spent a fair few hour debugging and have a compelling need to get fixed.

dmanners commented 5 years ago

Hey @adam-paterson are we still waiting on a backport here or is this all covered now?

ladle3000 commented 5 years ago

I've got some incomplete SQL queries I've been testing and using to add and remove new bundle selections. Let me know if you're interested.

On Mon, Oct 22, 2018, 6:47 AM David Manners notifications@github.com wrote:

Hey @adam-paterson https://github.com/adam-paterson are we still waiting on a backport here or is this all covered now?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/magento-engcom/import-export-improvements/issues/80#issuecomment-431790723, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQbJYVasrwL5oRqW1fjmDmDL7OMpd-rks5unaIqgaJpZM4RR6C4 .

-- Scott Noroozi

dmanners commented 5 years ago

This has been covered in 2.3 by @adam-paterson and in 2.2-develop with the commit https://github.com/magento/magento2/commit/ec8830fcd9b86ce75aa2a3cc685fa83316dcc971#diff-2456e1e4a327efb1a7617a7ce822b66c.

Thanks for all that helped here.