Magento - Get Subcategories on a Category Page

To list down your subcategories in the category page all you have to do is creating a static block and then assigning the parent category to that block with few other settings. Just go through the below steps to achieve this in your magento website.

  • Go to Magento admin panel > CMS > Static blocks. Create new static block with identifier subcategory_listing with the content "{{block type="catalog/navigation" template="catalog/navigation/subcategory_listing.phtml"}}"
  • Save your block and navigate to Catalog > Manage categories. Select the parent category which contains subcategories. Under the display settings tab change the settings as below:
    Display mode: Static block only; Only CMS Block: subcategory listing; Is Anchor: No and save the category.
  • Now create new file subcategory_listing.phtml in app/design/frontend/default/{Your Custom Theme}/template/catalog/navigation and copy the below code: 

<div class="category-products">
<ul class="products-grid">
<?php
$_categories=$this->getCurrentChildCategories();
if($_categories->count()):
$categorycount = 0;
foreach ($_categories as $_category):
if($_category->getIsActive()):
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
$catName = $this->getCurrentCategory()->getName();
if ($categorycount == 0){
$class = "first";
}
elseif ($categorycount == 3){
$class = "last";
}
else{
$class = "";
}
?>
<li class="item <?=$class?>">
<a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>"><img src="<?php echo $_category->getImageUrl() ?>" width="100" alt="<?php echo $this->htmlEscape($_category->getName()) ?>" /></a>
<h2><a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a></h2>
</li>
<?php
endif;
if($categorycount == 3){
$categorycount = 0;
echo "</ul>\n\n<ul class=\"products-grid\">";
}
else{
$categorycount++;
}
endforeach;
endif;
?>
</ul>
</div>

From Magento Admin panel -> Manage Categories -> Go to the category that contains sub categories -> Under Display Settings Tab -> Select Display mode as: Static block only; CMS Block: subcategory_listing  ;Is Anchor: No and save category.

Go to your front end website and go to that category page. You will see a list of subcategories :)

Hope this helps to solve someone's problem ! For any other queries please feel free to write us at prashcreations(at)gmail(dot)com

20 comments:

  1. Wow, Excellent post. This article is really very interesting and effective. I think its must be helpful for us. Thanks for sharing your nice post.
    memory trainings

    ReplyDelete
  2. Viagra war die allererste rezeptpflichtige Behandlung gegen Impotenz. Man schätzt, dass weltweit über 20 Millionen Männer mit diesem Medikament erfolgreich behandelt worden sind. Es ist in 88% der Fälle wirksam Männern zu helfen, die Mühe haben eine Erektion zu erreichen und aufrecht zu erhalten und besseren, zufrieden stellenderen Geschlechtsverkehr zu geniessen.
    Viagra Kaufen

    ReplyDelete
  3. very good article [url=www.prothom-alo.com]PROTHOMALO[/url]

    ReplyDelete
  4. phen375 Reviews Phen375 diet pill review. Find out what it is and how it can benefit you in your weight loss problems.

    ReplyDelete
  5. Leaks can be caused by bad valves We want to be your plumbers for life! We offer just about every plumbing service you'll ever need, delivered by the friendliest and most talented plumbers the industry has to offer.

    ReplyDelete
  6. Summed up simply, we integrate and implement 360º creative communication solutions in Iran.

    Outside of Iran this term might be divided into branding, advertising, PR or media solutions and have words such as digital or events added, but Iran, for multiple reasons is different.

    For over 15-years we’ve mastered those disciplines individually – integrating international standards where appropriate, and local practices where necessary.

    We’re not different from others in the industry, in that we comfortably cross disciplines, but we are different in that we get great results – be them with branding and advertising, digital or events – over an insistence on implementing international standards in zigma8 full service advertising agency.

    ReplyDelete
  7. ValidCoupons.net offering big selection coupon codes, discounts coupons and deals. Find great deals.

    ReplyDelete
  8. FlowerDeliveryNYC.com is a company that aims to provide the highest quality floral arrangements for you to make your event or occasion stand out. What distinct www.FlowerDeliveryNYC.com from other florists is that they are high professionals and not telemarketers. The company promises to offer its services all 7 days a week and 365 days a year with a prompt delivery on the very same day you order to make your occasion an everlasting one. We make sure to consider your event as our own and provide with services that can make your event a hit.
    Products
    Tiniest details matter the most. Whether it is a simple thank you, congratulations, get well soon, sorry, or love and romance, we have got it all covered for you. When you place an order with us, you obviously want it to be done right. We promise to fill every order exactly as it is required by the customer.
    Our products are divided under the categories of;
    • Luxury collection
    • Corporate gifts
    • Gift baskets
    • DOG – able collection
    Whether it is happy news or a sad one, flowers are something that is required at any sort of occasion. For the happy occasions like birthdays, anniversary, graduation, sorry, I am thinking of you or get well soon we have a whole different variety of flowers. Whereas, when it comes to sympathy, we have a huge collection of baskets, vase arrangements, casket sprays, standing sprays, crosses, hearts and baskets.
    Corporate Services
    To make you feel refreshed every Monday after a fulfilled weekend, www.FlowerDeliveryNYC.com provides fresh arrangements for your boardroom or corporate reception area with a new arrangement delivered each week. The arrangement is set and designed from the in-season flowers.
    www.FlowerDeliveryNYC.com are professional florists that take their work very seriously hence, come in to your office, check the environment to determine the lighting and size to provide with the suitable flower arrangement.
    Delivery
    We believe that our customers and their occasions are equally important to us as if it were our own, which is why www.FlowerDeliveryNYC.com has hired a dedicated professional staff to make your experience a pleasant one. The staff goes an extra mile to give you an outstanding service by making your floral gift perfect.
    There are various delivery policies mentioned on our official website so do have a look on them before placing your order. However, we assure you to deliver you what you desire at the requested time frame in the special instruction box when you order. You can also send a message to your loved one or the recipient of the gift on the Card Message field that comes with the gift.
    What makes us the best in New York City is that we make sure to keep every minor detail in mind and not leave the orders we receive to a computer but personally administer them. We also believe we offer the best value among other florists.
    Give us a chance to be your first choice when it comes to flowers.

    ReplyDelete
  9. We are a licensed moneylender company, providing low interest legal loans. Fast cash, instant approval! Best deal in Singapore. Contact us today!

    ReplyDelete

  10. Seaside Residences East Coast Park
    is the first new launch condominium projects with sea view that will be built along East Coast Park in 15 years. According to the developer ...

    ReplyDelete
  11. tarotRencontrez une voyante en ligne au numero de telephone indique sur notre site web. Avec le tarot, le pendule ou l'astrologie, votre destin pourra vous etre devoile sans attente. Ne restez pas plus de temps entrave(e) par l'incertitude et la peur du lendemain. Des aujourd'hui, vous pouvez obtenir des informations precieuses en ligne qui vous permettront de voir l'avenir avec plus de confiance et de certitudes.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. " olympicbodyfuel " Nowadays, many people start to follow an effective diet routine or an exercise plan that assure them the quick and greatest result. People are willing to follow these plans as they want to look attractive regardless of any other thing. All they want to look beautiful and catchy. The people which are following the muscles building plan may follow the SMART principle as by applying these principal they can achieve their goals and plan and the dreams which they want to see in reality. You can use “D bal Max” in your routine if you want to achieve your desired target.

    ReplyDelete
  14. " Woocommerce connector integration " Woocommerce is a popular shopping cart DSYNC helps to connect Woocommerce to XML, JSON apps, Salesforce, Revel Systems, Quickbooks, XERO, drop shipping and inventory suppliers. DSYNC is used to sync data between multiple applications and joins systems together.

    ReplyDelete
  15. " Car Insurance Agency Pearl City HI " As a Personal Financial Representative in Pearl City, I know many local families. My knowledge and understanding of the people in this community help me provide customers with an outstanding level of service. I look forward to helping families like yours protect the things that are important – your family, home, car and more. I can also help you prepare a strategy to achieve your financial goals.

    ReplyDelete
  16. " Rent a Yacht in Cabo " At Luxury Yachts Cabo, we love the yacht lifestyle. And we want to share that lifestyle with you! We've been working in the Rent a Yacht in Cabo business for years and love to share our expertise with our customers. No matter what your needs, what you've always dreamed your yacht experience will be, we will bring it to you. If you want a small, family cruise or a large yacht party, we'll put it all together for you.
    From the boat to the captain to the music and drinks, we'll handle everything.

    ReplyDelete
  17. hampton bay ceiling fans Online shopping for Tools & Home Improvement from a great selection of Ceiling Fans, Accessories, Ceiling Fan Light Kits & more at ...

    ReplyDelete