Hi,
We can use the following code to get the products under a category.
$_categories=$this->getCurrentChildCategories();
$_category = $this->getCurrentCategory();
$subs = $_category->getAllChildren(true);
$result = array();
foreach($subs as $cat_id) {
$category = new Mage_Catalog_Model_Category();
$category->load($cat_id);
$collection = $category->getProductCollection();
foreach ($collection as $product) {
$result[] = $product->getId();
}
}
shuffle($result);
?>
We can use the following code to get the products under a category.
$_categories=$this->getCurrentChildCategories();
$_category = $this->getCurrentCategory();
$subs = $_category->getAllChildren(true);
$result = array();
foreach($subs as $cat_id) {
$category = new Mage_Catalog_Model_Category();
$category->load($cat_id);
$collection = $category->getProductCollection();
foreach ($collection as $product) {
$result[] = $product->getId();
}
}
shuffle($result);
?>
No comments:
Post a Comment