I used Category Collection but is show error in product count is fixed it but after that is show error in Set product is and attribute set.
I am trying this by Problematically.
My code:
$storeId = $_SESSION["store_id"] ? $_SESSION["store_id"] : $this->session->userdata('store_id');
public function get_categories()
{
$storeId = store_id;
$web_id = website_id;
$rootCategoryId = Mage::app()->getStore($storeId)->getRootCategoryId();
$categories = Mage::getModel('catalog/category')
->getCollection()
->setStoreId($storeId)
->addFieldToFilter('is_active', 1)
->addAttributeToFilter('path', array('like' => "1/{$rootCategoryId}/%"))
//->setProductStoreId($storeId)
->addFieldToFilter('store_id',$storeId)
// ->setLoadProductCount(1)
->getSize(1)
// ->addAttributeToSelect('*')
// ->addAttributeToSelect(array('name'),'inner')
->addAttributeToSelect(array('name','url'));
foreach ($categories as $_category)
{
$img = $_category->getImageUrl();
$data[] = array('category_id' => $_category->getEntityId(), 'category_name' => $_category->getName(), 'image' => $imgUrl);
}
return $data;
}
Now this code is showing Fatal error: Call to a member function addAttributeToSelect() on a non-object
setPageSize
instead ofgetSize
method.