I am developing a magento site where there is a left sidebar called "shop by category" by default in magento theme. I have created a category and there are some subcategories under parent category. When I go to parent category, it shows list of products as well as left sidebar with subcategories. But when I select subcategories, it shows list of products but left sidebar is missing. Is there any way to rectify it from admin or code level.
Magento 1.9 – Fixing Missing ‘Shop by Category’ on Subcategory Page
categorymagento-1.9product-list
Best Answer
Layout wise, magento distinguishes categories as
default categories
andlayered categories
. Magento usesis anchor
option in order to make this categorization. Ifis anchor
is set toyes
, then that category would belayered category
and if it is set tono
, then that category will treat as adefault
catetgory.What happens when we set the property
is anchor
to yes ?Then the category will become a layered category. A category which holds layered navigation section along with it. Layered navigation will hold product attribute list which we set to include in layered in layered navigation so that we can filter products in a particular category using those product attriubte.
color
attribute is an example.Another important thing about layered category - it will display all products not only from the selected category, but from its subcategories.
In this case, magento will process a unique layout handle
catalog_category_layered
.What happens when we set the proeprty
is anchor
to no ?Now these categories become default categories. Categories which will not show layered navigation section. So product attribute filtering is not possible for this type of categories.
Also a default category only show products which are assigned with that category itself. There is no possibility that it will show products that comes under its child categories.
In this case, Magento will process a unique layout handle
catalog_category_default
.What is the problem here ?
You set all of your categories to default, coz
is anchor
property of all categories is set to no in your case.There is very interesting point that I need to share with you in this case. If you take Magento's default theme (
base/default
), you can see that, layout handle for default categoriescatalog_category_default
actually defines a left section. It looks like this.File :
app/design/frontend/base/default/layout/catalog.xml
This means it uses the block of type
catalog/navigation
in theleft
section. This block is actually responsible for the left content that you are viewing in adefault category
.If you check inside
catalog_category_layered
, it uses another block of typecatalog/layer_view
to show the left section. So this block is obviously used to show the layered navigation section.So the question is what is
catalog/navigation
block does for default categories ?To answer the question, please have a look on the template file which is set with this block
You will find this line there.
It is clear that it collects all of its child categories and show as a link to filter. This means
category filtering is always available in every category irrespective of the value set to the field
is anchor
So if you can see categories for a parent category and it seems empty for a child category, then that means the child category that you are describing actually does not hold any other child categories. At least this is the default case.
If the child category that you are referencing actually holds other child categories, then I am sure that some customization on the default behaviour is took place and you need to trace it out !!