我希望在magento的单个页面上显示所有类别(包括名称,描述等等详细信息)及其产品(包括名称,价格,添加到购物车选项等)。
请建议,如何做到这一点?
提前致谢!
最诚挚的问候,
答案 0 :(得分:0)
获取所有产品:
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*');
foreach ($collection as $product) {
echo $product->getName() . "<br />";
}
link从
复制的地方并获取所有类别:
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*');
从复制的答案 1 :(得分:0)
$rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$category = Mage::getModel('catalog/category')->load($rootCategoryId);
// get all sub categories of the root category
$subCategory = $category->getChildrenCategories();
// display parent category of the current category
$currentCategory = Mage::registry('current_category');
echo $this->getCurrentCategory()->getParentCategory()->getName() ;
/* another sample */
$currentCategory = Mage::registry('current_category');
// display sub-category of current category
if ($currentCategory->getParentId() == Mage::app()->getStore()->getRootCategoryId())
{
// current category top-level category
$rootCategory = $currentCategory;
}
else {
// current category sub category of top-level category
$rootCategory = Mage::getModel('catalog/category')->load($currentCategory->getParentId());
}
$subCategory = explode(',', $rootCategory->getChildren());
foreach ( $subCategories as $subCategoryId )
{
$categories = Mage::getModel('catalog/category')->load($subCategoryId);
// get status of category
if($categories ->getIsActive())
{
echo '<a href="'.$categories->getURL().'">'.$categories->getName().'</a>';
}
}