Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if the product exists in the system before adding to comparing list. #23073

Closed
wants to merge 14 commits into from
Closed

Conversation

adarshkhatri
Copy link
Contributor

@adarshkhatri adarshkhatri commented May 31, 2019

Check if the product exists in the system before adding to comparing list.

Description (*)

Check if the product exists in the system before adding to comparing list. If the product doesn't exist, then we simply do nothing.

Fixed Issues (if relevant)

  1. Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails  #23071: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

Manual testing scenarios (*)

  1. Use this url http:://www.domain.com/catalog/product_compare/index/items/ab
  2. Use this url http:://www.domain.com/catalog/product_compare/index/items/1234567890
    Make sure product ID doesn't exist in the system.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

Check if the product exists in the system before adding to comparing list. If the product doesn't exist, then we simply do nothing.
@m2-assistant
Copy link

m2-assistant bot commented May 31, 2019

Hi @adarshkhatri. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@adarshkhatri
Copy link
Contributor Author

@magento give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri, here is your new Magento instance.
Admin access: https://pr-23073.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@dmytro-ch dmytro-ch self-assigned this May 31, 2019
@dmytro-ch dmytro-ch self-requested a review May 31, 2019 05:33
@arnoudhgz
Copy link
Contributor

@adarshkhatri @dmytro-ch Is it not better to check if the product exists as first thing in the addProduct method? It does not make sense to do anything else (like _addVisitorToItem and loadByProduct) in this method if the product does not exist.

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After changes are applied and all builds are green, please squash them into a single commit so that we have perfectly clean history 😉

@ghost ghost assigned orlangur Jun 5, 2019
Using searchCriteriaBuilder to get the products from the system, filtered by (passed) productIds and then iterate that list of products to add to compare list.
@adarshkhatri
Copy link
Contributor Author

@magento give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri, here is your new Magento instance.
Admin access: https://pr-23073.instances.magento-community.engineering/admin
Login: admin Password: 123123q

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After changes are applied and all builds are green, please squash them into a single commit so that we have perfectly clean history 😉

@@ -51,6 +51,18 @@ class ListCompare extends \Magento\Framework\DataObject
*/
protected $_compareItemFactory;

/**
* Product Repository
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such comment is useless, please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

Adding backward compatibility for constructor parameters.
Fixing typo "_condProdCombineF". Replacing it with "_condProdCombineFactory".
@ghost ghost assigned sidolov Aug 16, 2019
@m2-assistant
Copy link

m2-assistant bot commented Aug 27, 2019

Hi @adarshkhatri, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Currently, the system tries to add any product id in to compare list, which is why it fails and throws an error.

Allow only existing products to be added to compare list.
@m2-assistant
Copy link

m2-assistant bot commented Sep 6, 2019

Hi @adarshkhatri. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@ghost ghost unassigned orlangur, sidolov and dmytro-ch Sep 6, 2019
@adarshkhatri
Copy link
Contributor Author

@magento give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri, here is your new Magento instance.
Admin access: https://pr-23073.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@sidolov
Copy link
Contributor

sidolov commented Sep 23, 2019

@adarshkhatri please, cover changes with automated tests

@adarshkhatri
Copy link
Contributor Author

@adarshkhatri please, cover changes with automated tests

I Couldn't understand them.

First fail:

PHP Code Mess has found error(s):
/var/www/html/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php:20 The class Magento\Catalog\Model\Product\Compare\ListCompare uses sessions or cookies while not being a part of HTML Presentation layer

Failed asserting that 2 matches expected 0.

Second fail:

Database Compare / Database Compare build failing 12 days ago in 30m 38s
No build reports available

@sidolov
Copy link
Contributor

sidolov commented Sep 27, 2019

@adarshkhatri test failures caused by legacy implementation and you don't need to fix them. Please, cover newly added logic by tests

@adarshkhatri
Copy link
Contributor Author

@adarshkhatri test failures caused by legacy implementation and you don't need to fix them. Please, cover newly added logic by tests

Just couldn't understand what's the logic added by test in this?

Should I just add @SuppressWarnings(PHPMD.CookieAndSessionMisuse) in the class?

Thanks.

@sidolov
Copy link
Contributor

sidolov commented Oct 4, 2019

@adarshkhatri usage of the repository was added to the method, it should be covered at least by unit test.

@dmytro-ch
Copy link
Contributor

dmytro-ch commented Oct 23, 2019

Closing this PR due to inactivity.
Feel free to reopen this PR if you wish to proceed.
Thank you!

@dmytro-ch dmytro-ch closed this Oct 23, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 23, 2019

Hi @adarshkhatri, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

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

Successfully merging this pull request may close these issues.

6 participants