Skip to content

#18624 Refactoring: Extract addLinks to own class #21658

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

Closed

Conversation

amenk
Copy link
Contributor

@amenk amenk commented Mar 8, 2019

WIP

follow up of #21230

Aim is to refactor product links during import, with the final aim of an extension point to import own relation types

@magento-engcom-team
Copy link
Contributor

Hi @amenk. 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-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

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

@amenk amenk marked this pull request as ready for review March 8, 2019 16:12
@amenk
Copy link
Contributor Author

amenk commented Mar 8, 2019

Still WIP, but want to kick of the CI for some full tests

@amenk
Copy link
Contributor Author

amenk commented Mar 8, 2019

Todo

[ ] Inject LinkProcessor via DI (I think we need a factory)
[ ] Maybe optimized passed classes (help-wanted)
Currently it's quite stupid:

     $linkProcessor = new LinkProcessor( // FIXME: instantiate via DI (but there are som
            $this,
            $this->_connection,
            $this->_linkFactory,
            $this->_resourceHelper,
            $this->_dataSourceModel,
            $this->skuProcessor,
            $this->_logger,
            $this->getProductEntityLinkField()
        );

@amenk amenk changed the title #18624 Refactoring: Extract addLinks to own class without BC break #18624 Refactoring: Extract addLinks to own class Mar 9, 2019
@amenk
Copy link
Contributor Author

amenk commented Mar 9, 2019

  • integration tests fail of strange reasons (not sure if related to my change or bug in the CI server)
  • di.xml config is not optimal -- it would be cool to use init_parameter but it does not seem to be allowed in arrays, who to do?

@amenk amenk requested a review from orlangur March 9, 2019 13:01
@rogyar
Copy link
Contributor

rogyar commented Mar 13, 2019

Hi @amenk. Regarding the integration tests, take a look at:

https://github.com/magento/magento2/pull/21658/files#diff-355bef4df35549f0f67776426f504636R208

I believe, there's no isSkuExist method within the scope of this class.

@ghost ghost assigned dmanners Mar 21, 2019
@amenk
Copy link
Contributor Author

amenk commented Mar 21, 2019

@dmanners Thanks for your review.

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request @amenk ! Please see my code review comments

@ghost ghost assigned sivaschenko Mar 21, 2019
@amenk amenk requested a review from sivaschenko April 6, 2019 19:19
@amenk
Copy link
Contributor Author

amenk commented May 8, 2019

Now a conflict appeared :-( Have to review this.

is this otherwise ready to merge?

@amenk
Copy link
Contributor Author

amenk commented May 8, 2019

Conflicts solved -- was only static tests suppression

@amenk
Copy link
Contributor Author

amenk commented May 8, 2019

@sivaschenko Which of the failing builds do I have to tackle?

  • Sample Data Tests build does not provide a report
  • Semantic Version Checker: suggests a MINOR bump, which should be fine, right?
  • Magento Health Index: Should I tackle that protected variable message?

@amenk
Copy link
Contributor Author

amenk commented May 20, 2019

@sivaschenko Which of the failing builds do I have to tackle?

  • Sample Data Tests build does not provide a report
  • Semantic Version Checker: suggests a MINOR bump, which should be fine, right?
  • Magento Health Index: Should I tackle that protected variable message?

And what about the static tests?

When I run LiveCodeTest locally I do not get those errors: (see https://testing-service.magento-community.engineering/reports/magento/magento2/pull/21658/7df8ac0b-32e5-4377-aebc-7dbf531faa3c/6412/Statics/allure-report-ce/index.html#suites/51d3ab4d5d77a0bc6a7ea344e9e7e6be/5823c27e50eef3c2/)

Is this test not idempotent?

@amenk
Copy link
Contributor Author

amenk commented May 26, 2019

@odubovyk also worked on the refactoring of this part - which is great... I think I have to start over with extracting the code to a seperate class. It is very demotivating, that my pull request did not receive attention for almost weeks

@amenk
Copy link
Contributor Author

amenk commented May 26, 2019

@odubovyk Would you be willing to extract the link processing code, to a separate classes as well as allowing injecting additional link types?

@DanielRuf
Copy link
Contributor

It is very demotivating, that my pull request did not receive attention for almost weeks

Sorry to hear this but most of us do this here only in their free time as hobby and there are many open PRs and issues - there is just much to do.

@amenk
Copy link
Contributor Author

amenk commented May 26, 2019

It is very demotivating, that my pull request did not receive attention for almost weeks

Sorry to hear this but most of us do this here only in their free time as hobby and there are many open PRs and issues - there is just much to do.

yes, agreed, me, too :-) Already trying to get motivated again ... I hope I can work with @odubovyk together to extract his code to a separate class to get the link-types injected. His work anyways seems to have some additional improvements to this part of the code (for example reducing cyclomatic-complexity), but it's all kept in the original Product-"God"-Class

@sivaschenko
Copy link
Member

Hi @amenk , thanks for your patience! Sorry, I might have skipped reviewing this PR as I was probably confused by "WIP" in the first line of description. A great refactoring has been done here!

As for tests:

  • An optional parameter added to the constructor has to be approved by @akaplya
  • The access level of protected property reported by Magento Health Index should be changed to private
  • The cyclomatic complexity reported by static tests should be reduced

I am also concerned by introducing new public methods to app/code/Magento/CatalogImportExport/Model/Import/Product.php as that's an API class and such changes are not backward compatible. Is it possible to avoid this change

@amenk
Copy link
Contributor Author

amenk commented May 29, 2019

Thank you. Actually there are major merge conflicts now and the process of refactoring might have to be done again. The good thing is that things like cyclomatic complexity were already fixed there. Have to check again.

@amenk
Copy link
Contributor Author

amenk commented Jun 10, 2019

I am trying to re-do the PR currently.

@amenk
Copy link
Contributor Author

amenk commented Jun 10, 2019

follow up PR:

#23191

@sivaschenko @DanielRuf @dmanners

@amenk amenk closed this Jun 10, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jun 10, 2019

Hi @amenk, 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.

magento-engcom-team added a commit that referenced this pull request Mar 19, 2020
…23191

 - Merge Pull Request #23191 from iMi-digital/magento2:refactor-addlinks-to-own-class-take-3
 - Merged commits:
   1. a269519
   2. 095c434
   3. 84ccd7f
   4. 3b2a4fe
   5. f06e4d7
   6. 7dbdfd5
   7. 39542fd
   8. 4fbbcf1
   9. dd124e8
   10. e8e164f
   11. 37ad6a2
   12. 11c3525
   13. 502d66e
   14. e05bb10
   15. d437cec
   16. 5ca49ae
magento-engcom-team added a commit that referenced this pull request Mar 19, 2020
Accepted Community Pull Requests:
 - #27237: #26749: Saving CMS Page Title from REST web API makes content empty (by @engcom-Charlie)
 - #27215: Cleanup ObjectManager usage - Magento_Translation (by @Bartlomiejsz)
 - #27191: 26827 Added improvements to product attribute repository (save method) (by @sergiy-v)
 - #27125: #27124: Update wishlist image logic to match logic on wishlist page (by @mtbottens)
 - #23191: Refactor addlinks to own class take 3 (follows #21658) (by @amenk)
 - #25734: Experius 2.3 patch catalog flat (by @lewisvoncken)
 - #27273: MFTF: Test isolation, consistent naming (backwards-compatible) (by @lbajsarowicz)
 - #26015: Remove media gallery assets metadata when a directory removed (by @rogyar)


Fixed GitHub Issues:
 - #26827: 500 when creating new product after adding attribute via API and assigning to attribute set via UI (reported by @vincentteyssier) has been fixed in #27191 by @sergiy-v in 2.4-develop branch
   Related commits:
     1. acfc589
     2. fcf734f

 - #27124: Share Wishlist Email: Image Logic Issue (reported by @mtbottens) has been fixed in #27125 by @mtbottens in 2.4-develop branch
   Related commits:
     1. 854761d
     2. 12ae6e5
     3. 76e61ae
     4. 428605d
     5. b2d0793
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