Check if subcategory exists in current category
|
I have the
following category setup in my magento store:
I need to be able
to check if the category
misc exists
as a subcategory in my current category or not, and if so show a
particular block.
So if i was in the
kitchen category it would not show but in bedroom and bathroom it
would.
How can i do this
this check?
|
|
|
You can get the
list of subcategories of a category like this:
If you want to
check if only a specific category is present...in your case with
the name 'misc' just add an additional filter to the code above:
And you don't even
need to load the full collection. You just need to check if the
collection from above has at least 1 item in it.
|
No comments:
Post a Comment