This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Fix Product categories, Product Tags & Keyword filter not working in Products block #8377
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8beb36b
Fix product categories & keyword filter not working
imanish003 37f0ba0
Fix Product tags filter not working
imanish003 1954437
Merge branch 'trunk' into fix/8249-filters-not-working
imanish003 4095396
Merge branch 'trunk' into fix/8249-filters-not-working
imanish003 db26bdb
Make code readable by creating functions for the different parts of t…
imanish003 be0610f
Merge branch 'trunk' into fix/8249-filters-not-working
imanish003 6f871e2
Merge branch 'trunk' into fix/8249-filters-not-working
imanish003 e6bd862
Make function generic by including all taxonomies
imanish003 a5b2482
Minor improvements based on PR feedback
imanish003 4ad1ae9
Move null check for tax_query to function
imanish003 40b78a4
Merge branch 'trunk' into fix/8249-filters-not-working
imanish003 0039f49
Merge branch 'trunk' into fix/8249-filters-not-working
imanish003 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sunyatasattva @gigitux Can you please take a look at this PR? I have a query regarding these lines of code.
As I am not sure what else could be there in
$query['tax_query']
, therefore I have createdget_filter_by_product_categories_or_tags_query
function to extract queries related to only Product categories & Product tags.I am wondering if we could use
$query['tax_query']
as it is 🤔 Is there any possibility of extra items in$query['tax_query']
which we won't need & therefore we need to extract only what we need((For example, only Product categories & tags))?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I can see that there is get_global_query function. But code of this function only runs if
is_custom_inherit_global_query_implementation_enabled
is true.Only this function extracts
Keyword
which could be provided using "Filters" ToolsPanel available in Inspector Controls. Don't we needKeyword
when is_custom_inherit_global_query_implementation_enabled is false?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall exactly the reasoning behind it, as @gigitux has worked on that part of the code, but I believe it is intentional. Perhaps something to do with the interaction with filters blocks if we take
tax_query
as it is?Or maybe it was a prophylactic measure to enable the
custom_inherit_global_query
, which we eventually want to switch to.Yes, we definitely do. It must have been an oversight we didn't catch, as we were focused on implementing the custom inherit, before the scope was changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember very well, tbh 😭.
In any case, I think that we should not use the
$query['tax_query'] as it is
to be ready when we will switch to the custom inherit query logic.We already have the logic to merge the queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gigitux 👋
Got it, then the changes I made in this PR looks good to me. In short, I created
get_filter_by_product_categories_or_tags_query
function to extractproduct_tag
&product_cat
from thetax_query
as you can see here. Also, I extracted the keyword here. Please let me know if you notice any problem with this implementation.Right, but while calling
merge_queries
function, we were not passingtax_query
for product categories, product tags & keyword. I made the changes in this PR to pass these tomerge_queries
function.Please let me know if I misunderstood something & if you see any problem with changes I made in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gigitux That makes sense. There are two sections of filters in Editor i.e.
Advance Filters
&Filters
(see screenshot)As per my understanding, we are creating queries for Advance filters in get_queries_by_attributes (which isn't obvious from the name of function).
I am thinking to do one of the following:
get_filter_queries
& return queries forAdvance Filters
&Filters
from this function.get_advance_filter_queries
to make it more readable and clear. And, create new function calledget_filter_queries
which will return queries for product categories, product tags & keyword i.e. all the filters. Then passget_filter_queries()
as argument here.Which of these you think would be better approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That function generates queries by the custom attributes that the merchant sets via the editor. Furthermore, I think that there should not be a relationship between the UI and the name of the function of the backend.
So, I would create another function to create a valid query object starting from the $tax_query object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, maybe we can rename the function to
get_queries_by_custom_attributes
just to make it more readable & clear. What do you think? 🤔That makes sense. I will create a new function. Thanks for the feedback 🙌🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense! 👍
💪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gigitux I made the changes in this commit. Would you like to have a quick look?