For Such Interesting articles
Get a Free Quote
You will receive quote within 24 Hrs
-
Subscribe us
Sign up our newsletter
to get daily updates
How to Create Sub Categories On Magento?
These steps below explain how to list sub-categories on a category page:
1. First of all you need to go to the admin section of the Magento ecommerce website.
2. Go to the admin menu and select CMS > Static Blocks
4. You now need to create a new block called ‘Sub Category Listing’ with the following content:
{{block type=”catalog/navigation” template=”catalog/navigation/subcategory_listing.phtml” }}
2. Select Catalog > Manage Categories from the admin menu
3. Go to the ‘Display Settings Tab’ and select the category which has sub-categories to reflect the following:
>Display mode: Static Block only
>Only CMS Block: Sub Category Listing
>Is Anchor: No
4. Save this by clicking on the ‘Save Category’ on the top right section of the page.
5. Once that is done, create a new file by the name ‘subcategory_listing.phtml’ with the following content.
- Now use FTP to connect to your web server and then browser to where your Magento files are stored.
- Go to the directory app/design/frontend/default//template/catalog/navigation/ and upload this file created above. You can create the directories missing from the path above if required.
- While on the FTP connection is still alive you need to go to the directory app/code/core/Mage/Catalog/Block/Navigation.php and download the file navigation.php.
- While still on the FTP, navigate to the directory app/code/local/Mage/Catalog/Block and upload the copied navigation.php file to this directory.
- You the need to open the file navigation.php in your favourite editor and look for the following code:
public function getCurrentChildCategories()
{
$layer = Mage::getSingleton(‘catalog/layer’);
$category = $layer->getCurrentCategory();
/* @var $category Mage_Catalog_Model_Category */
$categories = $category->getChildrenCategories();
$productCollection = Mage::getResourceModel(‘catalog/product_collection’);
$layer->prepareProductCollection($productCollection);
$productCollection->addCountToCategories($categories);
return $categories;
}
Replace this code with the following:
public function getCurrentChildCategories()
{
$layer = Mage::getSingleton(‘catalog/layer’);
$category = $layer->getCurrentCategory();
/* @var $category Mage_Catalog_Model_Category */
$collection = Mage::getModel(‘catalog/category’)->getCollection();
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
$collection->addAttributeToSelect(‘url_key’)
->addAttributeToSelect(‘name’)
->addAttributeToSelect(‘is_anchor’)
->addAttributeToSelect(‘image’)
->addAttributeToFilter(‘is_active’, 1)
->addIdFilter($category->getChildren())
->setOrder(‘position’, ‘ASC’)
->joinUrlRewrite()
->load();
$productCollection = Mage::getResourceModel(‘catalog/product_collection’);
$layer->prepareProductCollection($productCollection);
$productCollection->addCountToCategories($collection);
return $collection;
}
- Now upload this file to the web server using the same FTP connection.
- That is it, you are done; if you browse to the frontend of the site and open the category with the sub-categories added to it should show the sub-categories listed.
- If in case they are not present you may need to clear the Magento cache first and then attempt load the page.
Feel free to contact our magento web developer team today.
Why Choose Alakmalak As a Your Growth Partner?
Alakmalak is a web development company in India that offers services for several technologies. There have been around for a very long time and have developed over 2500 projects for clients all around the world. They have highly skilled web developers with a great deal of experience.
Bonus: Download a PDF version of The Ultimate Guide to Avoid 10 BIGGEST IT Outsourcing MISTAKES. Access it offline anytime.
Get Instant Access: The Ultimate Guide to Avoid 10 BIGGEST IT Outsourcing MISTAKES
- How to Create Sub Categories On Magento?
What’s Next ?
I know after reading such an interesting article you will be waiting for more. Here are the best opportunities waiting for you.
-
-
Uncover our captivating services
-
Supercharge your business with us
OVER 600 Small, Medium and Large Enterprise business clients have chosen us from 35 COUNTRIES
-
Federico Bilcheswww.latmeco.com
I want to thank all Alakmalak team for take my project and help me to improve my website! Thank you for your responsibility and seriousness at the time to do corrections and improvements on my website and for always be in touch with me. Highly recommended! Great team! Great company! I'm very thankful Alakmalak!
-
Frank M. Cali.USA
A few kinds words to say about Alakmalak programming and design. Working with these guys is always such a great relief. You know you are getting your stuff done right and usually always in a timely fashion. I’m a middle man for the most part And my clients are always happy with the end result.