I am working on one website multi store functionality. I am having store view ids in my array, i want to get all categories by store view id arrays.
2 Answers
$categories = Mage::getModel('catalog/category')
->getCollection()
->addFieldToFilter('is_active', 1);
print_r($categories->getAllIds());
You can click refer following code..
<?php
require_once("app/Mage.php");
Mage::app('default');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
try
{
$entityType = Mage::getModel('catalog/product')->getResource()->getTypeId();
$collection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter($entityType);
$allSet = array();
foreach($collection as $coll)
{
$attributeSet['name'] = $coll->getAttributeSetName();
$attributeSet['id'] = $coll->getAttributeSetId();
$allSet[] = $attributeSet;
}
Mage::log($allSet,1,'allSet.log');//make sure you have enabled log fron backend
print_r($allSet);
$attributeType = Mage::getModel('eav/entity_type')->loadByCode(Mage_Catalog_Model_Product::ENTITY);
$attributeCollection = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($attributeType);
$allAttributes = array();
foreach($attributeCollection as $coll)
{
Mage::log($coll,1,'coll.log');
$attribute['name'] = $coll->getAttributeCode();
$attribute['id'] = $coll->getAttributeId();
$allAttributes[] = $attribute;
}
Mage::log($allAttributes,1,'allAttributes.log');//make sure you have enabled log fron backend
print_r($allAttributes);
}catch(Exception $e){
echo $e;
}
?>