How to Show Categories in Magento?

How to Display Categories in Magento?

To show categories in a Magento store, you ususally need to complete these steps:

  1. Create Categories: Ensure categories are set as children of the root category.
  2. Activate Categories: Make sure all categories are active. Inactive parent categories will hide their children.
  3. Navigation Option: Ensure "Use in Navigation" is set to "Yes" for each category.
  4. Store Configuration: Go to System -> Manage Stores and make sure the "Root Category" is set correctly.
  5. Update System: Clear the cache and refresh indexes.

If you want to give a definite admin user to edit categories apply our Magento Edit Lock. In case you want to track all the backend activities of your employees, use our Magento Admin Log extension.

 

How Can I Show Categories on the Homepage in Magento?

  1. Use Page Builder or Custom Code: While older versions suggested a "Catalog Categories List" widget, newer versions may require using Magento’s page builder or custom code solutions.
  2. CMS Page: Navigate to the CMS homepage in the admin panel and configure your display manually if needed.

 

How Can I Show Categories on the Left Sidebar of a Page in Magento?

To display categories on the left sidebar of a page in Magento, you can use the "Catalog Categories" block in the layout XML file of the page. First, navigate to the desired layout XML file in your custom theme or module. Next, add the following code to the XML file:

<referenceContainer name="sidebar.additional">
<block class="Magento\Catalog\Block\Navigation" name="catalog.leftnav" template="Magento_Catalog::navigation/left.phtml" before="-">
<arguments>
<argument name="is_active" xsi:type="boolean">true</argument>
<argument name="auto_expand" xsi:type="boolean">true</argument>
</arguments>
</block>
</referenceContainer>

This code will add the "Catalog Categories" block to the left sidebar of the page. You can customize the block by modifying the arguments in the XML file, such as changing the template or setting the category depth. Once you have saved the changes to the XML file, refresh the page to see the categories displayed on the left sidebar.

 

How Can I Show All Categories in the Layered Navigation in Magento 2?

By default, the layered navigation in Magento 2 only displays categories that contain products in the current catalog. However, you can modify this behavior and show all categories in the layered navigation by following these steps:

  1. Create a custom module or use an existing one to override the Magento_LayeredNavigation module.
  2. Modify the DataProvider.php file of the Magento_LayeredNavigation module to change the logic that filters the categories based on the current catalog.
  3. Modify the renderer.phtml file of the Magento_LayeredNavigation module to display all categories in the layered navigation, including those that do not contain products in the current catalog.

In the DataProvider.php file, you can modify the getItems method to query all categories instead of just those that contain products in the current catalog. You can also remove the filter that limits the categories to those in the current catalog.

In the renderer.phtml file, you can modify the code that generates the category filter options to include all categories, regardless of whether they contain products in the current catalog. You can also modify the code that generates the category URLs to ensure that they point to the correct pages, even if the categories do not contain any products in the current catalog.

By showing all categories in the layered navigation in Magento 2, you can provide a more comprehensive browsing experience for your customers, allowing them to explore your entire catalog and discover new products.

Loading

Didn’t you find the answer to your question? We are always happy to help you out.

Loading