Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $_cat = $this->getCurrentCategory();
- $_parent = $_cat->getParentCategory();
- $_categories = $_parent->getChildren();
- /* @var $category Mage_Catalog_Model_Category */
- $collection = Mage::getModel('catalog/category')->getCollection();
- /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
- $collection->addAttributeToSelect('url_key')
- ->addAttributeToSelect('name')
- ->addAttributeToSelect('is_anchor')
- ->addAttributeToFilter('is_active', 1)
- ->addIdFilter($_categories)
- ->setOrder('position', 'ASC')
- ->joinUrlRewrite()
- ->load();
- $productCollection = Mage::getResourceModel('catalog/product_collection');
- $layer = Mage::getSingleton('catalog/layer');
- $layer->prepareProductCollection($productCollection);
- $productCollection->addCountToCategories($collection);
- // $productCollection should be ready here ;-)
- ?>
- $productCollection = Mage::getResourceModel('catalog/product_collection')
- ->addCategoryFilter($category);
- $categoryId = 123; // a category id that you can get from admin
- $category = Mage::getModel('catalog/category')->load($categoryId);
- $products = Mage::getModel('catalog/product')
- ->getCollection()
- ->addCategoryFilter($category)
- ->load();
- print_r($products);
Add Comment
Please, Sign In to add comment