Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Get category of a store having his id
 
kareemzok
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2011-10-30
Lebanon
 

Is there any solution for how to get category using store id ?
for example i have store A and store B , i want to show category store A in Store B ,
so i tried these example but none worked

$categories Mage::getModel('catalog/category')
        ->
getCollection()
        ->
setStoreId(1);

and

$categories Mage::getModel('catalog/category')
        ->
getCollection()
        ->
addStoreFilter(1);

then i did a loop on it but no result .  plz help

foreach ($categories as $value{
    
echo $value->name;
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
MageKing
Member
 
Avatar
Total Posts:  54
Joined:  2010-08-28
Ahmedabad
 

Did you try?

$storeId 2;  //  REPLACE 2 WITH YOUR STORE ID
$categoryid Mage::app()->getStore($storeId)->getRootCategoryId(); // GETTING ROOT CATEGORY ID FOR STORE ID 2

$category_model Mage::getModel('catalog/category');

$_category $category_model->load($categoryid); //$categoryid for which the child categories to be found       
$all_child_categories $category_model->getResource()->getAllChildren($_category); //array containing all child categories id
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top