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

Fix URL generation for new store when it created with setup:config:import #30023

Conversation

ihor-sviziev
Copy link
Contributor

@ihor-sviziev ihor-sviziev commented Sep 14, 2020

Description (*)

Emulate adminhtml area where url rewrites are created

Related Pull Requests

Fixed Issues (if relevant)

  1. N/A

Manual testing scenarios (*)

  1. On Dev. env setup only one store view with few categories and products
  2. dump stores info to config.php with php bin/magento app:config:dump and commit it
  3. Deploy to production (run php bin/magento setup:upgrade --keep-generated on production env)
  4. On dev. env create second store view in the same Store Group and Website
  5. dump stores info to config.php with php bin/magento app:config:dump and commit it
  6. Deploy to production (run php bin/magento setup:upgrade --keep-generated on production env)

Expected result:
On second store view on dev and production environments were generated URL rewrites for categories and products.

Actual result:
On second store view URL rewrites were generated only on dev env (it was created via admin), but they weren't generated on production env (it was created during setup:upgrade command)

Questions or comments

My investigation shown that only in adminhtml area URL rewrites are generated when store view is created:

<type name="Magento\Store\Model\ResourceModel\Store">
<plugin name="store_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Store\View"/>
</type>
<type name="Magento\Store\Model\ResourceModel\Group">
<plugin name="group_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Store\Group"/>
</type>

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)

Resolved issues:

  1. resolves [Issue] Fix URL generation for new store when it created with setup:config:import #30025: Fix URL generation for new store when it created with setup:config:import

@m2-assistant
Copy link

m2-assistant bot commented Sep 14, 2020

Hi @ihor-sviziev. 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

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

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

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@ihor-sviziev
Copy link
Contributor Author

@magento run all tests

@ihor-sviziev
Copy link
Contributor Author

@magento create issue

@ihor-sviziev
Copy link
Contributor Author

@magento run all tests

@ihor-sviziev ihor-sviziev force-pushed the fix-url-generation-for-new-store-on-config-import branch from 0843a14 to 4dae97d Compare September 14, 2020 12:02
@ihor-sviziev
Copy link
Contributor Author

@magento run Static Tests

@ihor-sviziev ihor-sviziev marked this pull request as draft September 14, 2020 13:03
@ihor-sviziev
Copy link
Contributor Author

There some failures during setup:instal... need to fix it.

@sidolov sidolov added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Sep 14, 2020
@ihor-sviziev
Copy link
Contributor Author

@magento run all tests

@ihor-sviziev
Copy link
Contributor Author

@sidolov is there any instructions how to run & debug setup-integration tests?
I found the only instruction for running integration tests https://devdocs.magento.com/guides/v2.4/test/integration/integration_test_execution.html.

Also I checked - installing magento via php bin/magento setup:install works fine:
image

@ihor-sviziev
Copy link
Contributor Author

ihor-sviziev commented Sep 15, 2020

Ok... For now just updated test with some debug code in order to see what exact message error was there.

@magento run Integration Tests

@ihor-sviziev ihor-sviziev force-pushed the fix-url-generation-for-new-store-on-config-import branch from 9b45e3c to 4f49bba Compare September 15, 2020 10:13
@ihor-sviziev
Copy link
Contributor Author

@magento run Integration Tests

@ihor-sviziev ihor-sviziev force-pushed the fix-url-generation-for-new-store-on-config-import branch from 4f49bba to d1ceaf9 Compare September 15, 2020 12:00
@ihor-sviziev
Copy link
Contributor Author

@magento run Integration Tests

@sidolov
Copy link
Contributor

sidolov commented Sep 15, 2020

@ihor-sviziev do not forget about the extensions like MSI and ASI since the tests build contains them.

@ihor-sviziev
Copy link
Contributor Author

@sidolov as we discussed - it's not clear why this test fails, it fails for me even on 2.4-develop, also no instructions how to build them.

I'll keep this PR open only for internal investigation, I don't want to spend more time on fixing it, till we'll have some working instruction. Waiting for 2 hours for integration test results on CI is time wasting.

@Stepa4man
Copy link
Contributor

Stepa4man commented Sep 15, 2020

Hey, @ihor-sviziev. Nice that you decided to fix it. Thanks.
I have a question why did you decide to emulate adminhtml instead of fixing exact reason, why it's not generated from cli. No blaming or something, just curious what blockers are there?

@ihor-sviziev
Copy link
Contributor Author

@Stepa4man basically right now in the admin area declared plugins for generating url rewrites, so we have 2 options:

  1. emulating admin area (that I saw few times in other Cli commands, for instance config:set)
  2. moving these plugins to global level

<type name="Magento\Store\Model\ResourceModel\Store">
<plugin name="store_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Store\View"/>
</type>
<type name="Magento\Store\Model\ResourceModel\Group">
<plugin name="group_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Store\Group"/>
</type>

I went with 1st option because it was already used in some other cli commands and it seemed to me easier, also adding not needed plugin to the front end, web api, etc will just a bit slow down them due to additional inheritance and running additional code for managing plugins, etc.

If you have any other idea - let me know.

TBH I first time see that setup integration tests are failing at al. I found that we don’t have any instruction how to run them locally, tried to do similar to integration - they’re failing for me even on 2.4-develop branch. Running these tests on magento CI takes almost 2 hours (last run 1 h 55m), it’s crazy long time and not suitable for fixing the reason why it fails

@ihor-sviziev
Copy link
Contributor Author

@magento run Integration Tests

1 similar comment
@ihor-sviziev
Copy link
Contributor Author

@magento run Integration Tests

@ihor-sviziev ihor-sviziev force-pushed the fix-url-generation-for-new-store-on-config-import branch from 65e47a1 to 0d6c7bc Compare September 16, 2020 11:58
@ihor-sviziev
Copy link
Contributor Author

Failing functional looks not related to changes from my PR. All other failures I already fixed

Emulate adminhtml area where url rewrites are created
@ihor-sviziev ihor-sviziev force-pushed the fix-url-generation-for-new-store-on-config-import branch from ddab995 to 075ddb4 Compare September 17, 2020 09:18
@ihor-sviziev
Copy link
Contributor Author

ihor-sviziev commented Sep 17, 2020

@magento run all tests
Just rebased my changes, hope functional tests will not fail anymore

@ghost ghost moved this from Pending Review to Ready for Testing in Pull Requests Dashboard Sep 22, 2020
@ghost ghost assigned Stepa4man Sep 22, 2020
@magento-engcom-team
Copy link
Contributor

Hi @Stepa4man, thank you for the review.
ENGCOM-8243 has been created to process this Pull Request
✳️ @Stepa4man, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@Stepa4man Stepa4man added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Sep 22, 2020
@ghost ghost assigned lbajsarowicz Sep 22, 2020
@magento-engcom-team
Copy link
Contributor

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

@engcom-Alfa engcom-Alfa self-assigned this Sep 25, 2020
@engcom-Alfa engcom-Alfa moved this from Ready for Testing to Testing in Progress in Pull Requests Dashboard Sep 25, 2020
@engcom-Alfa
Copy link
Contributor

engcom-Alfa commented Oct 9, 2020

✔️ QA Passed

Manual testing scenario:

  1. On Dev. env setup only one store view with few categories and products
  2. dump stores info to config.php with php bin/magento app:config:dump and commit it

Screenshot from 2020-10-09 11-37-34

  1. Deploy to production (run php bin/magento setup:upgrade --keep-generated on production env)
  2. On dev. env create second store view in the same Store Group and Website in config.php file

2020-10-09_11-39

  1. Deploy to production (run php bin/magento setup:upgrade --keep-generated on production env)
  2. Go to Admin- > Marketing -> URL Rewrites;

Before: ✖️ On second store view URL rewrites were generated only on dev env (it was created via admin), but they weren't generated on production env.

Screenshot from 2020-10-09 10-25-12

After: ✔️ On second store view on dev and production environments were generated URL rewrites for categories and products.

2020-10-09_11-01

@engcom-Alfa engcom-Alfa added the QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope label Oct 9, 2020
@engcom-Alfa engcom-Alfa moved this from Testing in Progress to Extended Testing (optional) in Pull Requests Dashboard Oct 9, 2020
@engcom-Alfa engcom-Alfa moved this from Extended Testing (optional) to Merge in Progress in Pull Requests Dashboard Oct 9, 2020
@magento-engcom-team magento-engcom-team merged commit bd1cf08 into magento:2.4-develop Oct 15, 2020
@m2-assistant
Copy link

m2-assistant bot commented Oct 15, 2020

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

@ghost ghost moved this from Merge in Progress to Recently Merged in Pull Requests Dashboard Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Component: Deploy Priority: P3 May be fixed according to the position in the backlog. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Pull Requests Dashboard
  
Recently Merged
Development

Successfully merging this pull request may close these issues.

[Issue] Fix URL generation for new store when it created with setup:config:import
6 participants