Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

ImportExport: BEHAVIOR_REPLACE deletes products? #89

Open
piotrekkaminski opened this issue Jan 3, 2018 · 12 comments
Open

ImportExport: BEHAVIOR_REPLACE deletes products? #89

piotrekkaminski opened this issue Jan 3, 2018 · 12 comments

Comments

@piotrekkaminski
Copy link
Contributor

From @paales on August 4, 2016 14:51

Preconditions

  1. Magento 2.1.0

Steps to reproduce

  1. Import Product with BEHAVIOR_REPLACE set
  2. Import Product with BEHAVIOR_REPLACE set again

Expected result

  1. Same product ID is used, but all the values provided by the import are replaced

Actual result

  1. Product gets deleted and recreated...

It REALLY shouldn't delete the product because all other information related to this product gets lost. If a merchant has written anything store view specific, we want to retrieve reports by product ID, reviews placed on this product, etc.

I'm not sure how something like this happened, the BEHAVIOR_REPLACE doesn't mean replace the product, it means, replace complex values like custom options, configurable products or category associations (wtf?).

I will update this issue with suggestions how to solve this mess and how to solve the importer issues.

Copied from original issue: magento/magento2#5993

@piotrekkaminski
Copy link
Contributor Author

From @paales on August 4, 2016 15:12

Replace https://github.com/magento/magento2/blob/develop/app/code/Magento/CatalogImportExport/Model/Import/Product.php#L920

With:

$this->_saveProductsData();

The complete _replaceProducts method should be deleted from the class, git blame should be started and the developer responsible should treat the complete company apple pie! 😋

@piotrekkaminski
Copy link
Contributor Author

From @paales on August 5, 2016 9:10

It seems to be not as easy as removing the above lines. I'm getting the following when importing configurable products. Will report back when I know more.

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`promopost`.`catalog_product_super_attribute_label`, CONSTRAINT `FK_309442281DF7784210ED82B2CC51E5D5` FOREIGN KEY (`product_super_attribute_id`) REFERENCES `catalog_product_super_attribute` (`), query was: INSERT INTO `catalog_product_super_attribute` (`product_super_attribute_id`,`position`,`product_id`,`attribute_id`) VALUES (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?) ON DUPLICATE KEY UPDATE `product_super_attribute_id` = VALUES(`product_super_attribute_id`), `position` = VALUES(`position`), `product_id` = VALUES(`product_id`), `attribute_id` = VALUES(`attribute_id`)

@piotrekkaminski
Copy link
Contributor Author

From @paales on August 5, 2016 11:16

Two things:

  1. I didn't solve the integrity constraint violation.
  2. The table it gives the integrity constraint violation on doesn't have to be filled with the importer..

This methods generates the data:
https://github.com/magento/magento2/blob/6ea7d2d85cded3fa0fbcf4e7aa0dcd4edbf568a6/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php#L698-L724

You can see here that it generates a label for the attribute, but it currently isn't possible to set store view specific labels and we don't even want a label unique to each product.

So for now I've overwritten the method and just emptied it.

@piotrekkaminski
Copy link
Contributor Author

From @slopukhov on August 23, 2016 8:37

@paales thank you for your feedback.

This is the expected behavior for Replace action. Please read Magento user guide for more details.

I'm closing the ticket. Please feel free to reopen if you have additional questions.

@piotrekkaminski
Copy link
Contributor Author

it's definitely not intuitive behavior that needs further investigation. @ilol can you look into that?

@piotrekkaminski
Copy link
Contributor Author

From @ioliinyk on March 29, 2017 10:51

This is bug.

@piotrekkaminski
Copy link
Contributor Author

From @KrystynaKabannyk on April 18, 2017 15:54

Internal ticket is created MAGETWO-67547.

@piotrekkaminski
Copy link
Contributor Author

From @magento-engcom-team on September 29, 2017 6:30

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

@piotrekkaminski
Copy link
Contributor Author

From @PieterCappelle on December 22, 2017 19:39

I agree with @paales. REPLACE should be refactored or removed. Add/Update is also so wrong in many cases. When running add import it will add images to products, it will not overwrite them. Okay, I can understand but REPLACE is also no option like @paales is saying. In my opinion we should have one command for add/update/replace. :-)

@dmanners dmanners added this to the Phase 2 milestone Feb 13, 2018
magento-engcom-team added a commit that referenced this issue Mar 15, 2018
 - Merge Pull Request magento-engcom/php-7.2-support#89 from magento-engcom/php-7.2-support:update-zend-feed
 - Merged commits:
   1. b73d1c8
magento-engcom-team pushed a commit that referenced this issue Jun 21, 2018
…-Category

[architects] MAGETWO-92773: [GraphQL] Products cannot be fetched in parent/anchor category #89
@dmanners
Copy link
Contributor

My opinion here would be that we could consider updating the documentation and tool tips to help describe the settings for the import better.

@dmanners
Copy link
Contributor

So for this task what we are looking for here is 2 things:

  1. Updating the documentation,
  2. Adding UI labels via some form of hint icon,

Both of these should clearly describe what happens with the different flags for the import process. Especially the BEHAVIOR_REPLACE. We will not change the behavior at the moment but instead make the current behavior much more clearer in this ticket.

@dmanners dmanners removed their assignment Nov 13, 2018
@federivo federivo self-assigned this Nov 13, 2018
@lorikrell
Copy link
Contributor

Any updates need in documentation, I'm available to help in Merch Docs and DevDocs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants