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

Simplify logic for picking root category #68

Merged
merged 1 commit into from Jan 26, 2023

Conversation

rmilecki
Copy link

@rmilecki rmilecki commented Jan 15, 2023

Questions Answers
Description? Previous logic grew into a bit complex one. It had 2 conditional parts each checking for selected BLOCK_CATEG_ROOT_CATEGORY values. They were checking for different setups and later one was conditionally modifying result of the first one.

All of that made getWidgetVariables() code a bit hard to follow (understand) and hard to extend (add more scenarios).

This change cleans that up. It adds a switch() and handles each BLOCK_CATEG_ROOT_CATEGORY value with a separated code. It should make code easier to understand, debug & develop.
Type? refacto
BC breaks? no
Deprecations? no
Fixed ticket?
How to test? Open BO and navigate to the ps_categorytree module configuration. Select every "Category root" available option one by one and verify in FO they work as expected. This PR does not modify the behavior, it modifies how the code is written.

@rmilecki
Copy link
Author

@Hlavtox: I really like your work on dropping cookie usage in the #67 .

As for getWidgetVariables() logic however I think that handling each BLOCK_CATEG_ROOT_CATEGORY value separately would make code cleaner.

Would you be kind to look at my proposed change, please? Would you agree my logic with switch() solution makes this code any cleaner?

Previous logic grew into a bit complex one. It had 2 conditional parts
each checking for selected BLOCK_CATEG_ROOT_CATEGORY values. They were
checking for different setups and later one was conditionally modifying
result of the first one.

All of that made getWidgetVariables() code a bit hard to follow
(understand) and hard to extend (add more scenarios).

This change cleans that up. It adds a switch() and handles each
BLOCK_CATEG_ROOT_CATEGORY value with a separated code. It should make
code easier to understand, debug & develop.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Copy link
Contributor

@matks matks left a comment

Choose a reason for hiding this comment

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

Thank you @rmilecki nice PR 👍

I'm asking QA team if they can verify we changed no behavior

@matks matks added the waiting for QA Status: Waiting for QA feedback label Jan 25, 2023
@MhiriFaten MhiriFaten self-assigned this Jan 25, 2023
Copy link

@MhiriFaten MhiriFaten left a comment

Choose a reason for hiding this comment

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

Hello @rmilecki ,

I have checked every "Category root" available option one by one and they work as expectedin FO. 🎉
So it's QA approved ✔️

Thank you

@MhiriFaten MhiriFaten added QA ✔️ and removed waiting for QA Status: Waiting for QA feedback labels Jan 25, 2023
@nicosomb nicosomb added this to the 2.0.4 milestone Jan 26, 2023
@nicosomb nicosomb merged commit f70251e into PrestaShop:dev Jan 26, 2023
@nicosomb
Copy link
Contributor

Thank you @rmilecki !

@rmilecki
Copy link
Author

Thank you!

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