Magento: Get list of all Categories

Here, I will show you how you can get list of all categories of your Magento Shop. You might want to display all categories in homepage or any CMS page. There are different ways to get the category listing. Here are some:- Get all categories The following code will fetch all categories (both active and … Read more

Magento: Adding category attributes

Here, I will be showing you how you can add attributes for your categories in Magento. From the admin panel, you can only add attributes to product. To add attributes to category, you need to write sql query in your phpmyadmin or a better way would be creating a new custom module and adding attributes … Read more

Magento 1.4: No products displayed in category listing

Scenario: I have a fresh installation of Magento 1.4. I already have installed the sample data for Magento. Now, when I go to the category listing page, no products are displayed. It says “There are no products matching the selection.“. By category listing page, I mean the product listing page displayed when any category is … Read more

Magento: How to filter product collection using 2 or more category filters?

Suppose, you have a product collection and you want to filter it by category. Suppose, you want to filter it by more than one category. You can use addCategoryFilter if you have only one category. But, what if you want to filter by more than one category? Category ids are stored for product in a … Read more

Magento: Get current and parent category

This article shows how to get category information (category name, id, description, url, etc.) of the category page you are in. Along with the information of the parent category of the currently viewed category. Get current category // Get current category $currentCategory = Mage::registry('current_category'); Print current category array < pre> $currentCategory = Mage::registry('current_category'); echo " … Read more

Magento: Get sub categories and product count

This article shows how to get sub categories of a particular category and the number of products (product count) present in the sub categories. Suppose, you have a category named Furniture. The sub categories under Furniture are Living Room and Bedroom. Now, you want to show the sub categories under Funiture and the products associated … Read more

Magento: Get all categories name and url of a product

This article shows how you can fetch all the categories related/associated with a particular product. $product->getCategoryIds() function gives array of category ids with which the product is associated to. We can loop through this array and load each category to get the category name and url. // Load product $productId = 1; // YOUR PRODUCT … Read more