magento get categories using store id

magento get categories using store id

In this post we will show you magento get categories using store id, hear for magento get categories using store id we will give you demo and example for implement.

code for get categories using store id


$store_id = 1;
$get_store_categories_result = array();
$total_menu = $total_cat = 0;
try {
$get_store_root_category_id = Mage::app()->getStore($store_id)->getRootCategoryId();
$get_store_category_collection = Mage::getModel('catalog/category')->load($get_store_root_category_id);
$get_store_categories = $get_store_category_collection->getCollection()
->addAttributeToSelect(array('name', 'image', 'description','store'))
foreach($get_store_categories as $current_category_val)
$get_store_categories_result["categories"][$total_cat] = array(
"id" => $current_category_val->getId(),
"name" => $current_category_val->getName(),
"image" => Mage::getModel('catalog/category')->load($current_category_val->getId())->getImageUrl(),
"caturl" => $current_category_val->getUrl()
$total_cat = $total_cat + 1;
$get_store_categories_result["total"] = $total_cat;
catch(Exception $exception) {
$total_menu =  $get_store_categories_result['total'];
// display all category root
echo "<pre>";
echo "</pre>"; */

<div class="container">
<h2>magento get categories by store id</h2>
<ul class="submainnav submega-nav">
if($total_menu  > 0)
foreach ($get_store_categories_result['categories'] as $key => $value)
<li class="submainnavli">
<a class="submenu-link" href="<?php echo  $value['caturl']; ?>" id="submenus<?php echo $key; ?>">
<span class="submenu-title"><?php echo  $value['name']; ?></span>
<li class="submainnavli">No Categories Found</li>

Hope this code and post will helped you for implement magento get categories using store id. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

See also  Magento 2 Customize base directory path

Leave a Comment

Your email address will not be published. Required fields are marked *

3  +  5  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US