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

Reduce requirements for parameter in catalog product type factory #26821

Conversation

hws47a
Copy link
Contributor

@hws47a hws47a commented Feb 11, 2020

Description (*)

In the factory method, only API Interface method is used, but PHPDoc asks for the Product Model instead. Fix for this.

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)

@m2-assistant
Copy link

m2-assistant bot commented Feb 11, 2020

Hi @hws47a. 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.4-develop instance - deploy vanilla Magento instance

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

Copy link
Contributor

@novikor novikor left a comment

Choose a reason for hiding this comment

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

Hi, @hws47a .
Thank you for your contribution.
Except the changes provided, I think it would be nice to execute some code cleanup - at least replace fully qualified class names with import, and probably add missing @throws tags.
image

@hws47a
Copy link
Contributor Author

hws47a commented Feb 11, 2020

Hi @novikor, thanks for your review.

My idea is opposite, I do small changes but which bother me.
For example in this case I won't need to a check in a level above for
$product instance of \Magento\Catalog\Model\Product
after loading product from repository, which will simplify the code for me.

I believe in every single core class there are plenty of code which could be cleaned up, but it'll take ages if I'll start.

So please accept the PR as it is if it passes checks.

Copy link
Contributor

@novikor novikor left a comment

Choose a reason for hiding this comment

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

@hws47a, As you wish

@novikor novikor added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Feb 12, 2020
@magento-engcom-team
Copy link
Contributor

Hi @novikor, thank you for the review.
ENGCOM-6883 has been created to process this Pull Request

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

@engcom-Golf
Copy link
Contributor

Failed functional tests not related to the changes in this PR.
SVC fail is not valid as only one type was changed, need to approve SVC failure.

@novikor
Copy link
Contributor

novikor commented Feb 13, 2020

Hmm. There were no SVC failures at the moment of approval.
2 new commits created after caused that.

@novikor
Copy link
Contributor

novikor commented Feb 13, 2020

@Nazar65, please do not add new commits to PRs which are already approved next time :)

@novikor
Copy link
Contributor

novikor commented Feb 13, 2020

Failed functional tests not related to the changes in this PR.
SVC fail is not valid as only one type was changed, need to approve SVC failure.

It seems that SVC false alarm happened. There are no methods return types changes by the fact.

@hws47a
Copy link
Contributor Author

hws47a commented Feb 13, 2020

Thanks @novikor

@slavvka
Copy link
Member

slavvka commented Feb 20, 2020

The ticket to SVC approval https://jira.corp.magento.com/browse/MC-31723

@@ -164,7 +161,7 @@ public function priceFactory($productType)
* Get Product Price Info object
*
* @param Product $saleableItem
* @return \Magento\Framework\Pricing\PriceInfoInterface
Copy link
Contributor

@naydav naydav Feb 21, 2020

Choose a reason for hiding this comment

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

Changing of input/return annotations in docblocks should be reverted (for all methods except construct).
Theoretically, this class can be used in WebAPI requests.

The current implementation of WebAPI "request/response" parser has a limitation:

Valid object types include a fully qualified class name or a fully qualified interface name.
https://devdocs.magento.com/guides/v2.3/extension-dev-guide/service-contracts/service-to-web-service.html

Copy link
Member

Choose a reason for hiding this comment

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

@hws47a Please make changes according to @naydav comment.

@ghost ghost assigned naydav and slavvka Feb 21, 2020
@slavvka slavvka requested a review from novikor February 21, 2020 20:08
Copy link
Member

@slavvka slavvka left a comment

Choose a reason for hiding this comment

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

Please fix the PR according to @naydav comment

@ghost ghost dismissed slavvka’s stale review February 21, 2020 20:17

Pull Request state was updated. Re-review required.

@@ -116,8 +113,8 @@ public function __construct(
/**
* Factory to product singleton product type instances
*
* @param \Magento\Catalog\Model\Product $product
* @return \Magento\Catalog\Model\Product\Type\AbstractType
* @param ProductInterface $product
Copy link
Contributor

@engcom-Golf engcom-Golf Feb 21, 2020

Choose a reason for hiding this comment

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

@slavvka is this type also might be reverted ? or we can leave Magento\Catalog\Api\Data\ProductInterface?

Copy link
Member

Choose a reason for hiding this comment

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

Use full qualified type for ProductInterface. Don't import it.

Copy link
Contributor

@engcom-Golf engcom-Golf Feb 21, 2020

Choose a reason for hiding this comment

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

ok, i mean that in this case return type was changed from \Magento\Catalog\Model\Product to Magento\Catalog\Api\Data\ProductInterface

Copy link
Member

Choose a reason for hiding this comment

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

Exactly, without it there's no reason for making this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

done ✔️

@engcom-Golf
Copy link
Contributor

Hi @novikor could you please review this one again ?

@magento-engcom-team
Copy link
Contributor

Hi @novikor, thank you for the review.
ENGCOM-6883 has been created to process this Pull Request

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

@m2-assistant
Copy link

m2-assistant bot commented Feb 26, 2020

Hi @hws47a, 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
Labels
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Cleanup Component: Catalog Partner: Monsoon partners-contribution Pull Request is created by Magento Partner Progress: accept Release Line: 2.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants