0
我想显示所有类别(包括名称,说明等详细信息)及其产品(包含名称,价格,添加到购物车选项等)。 )在magento的单个页面上。如何在magento的单个页面上显示所有类别及其产品
请建议,如何做到这一点?
在此先感谢!
最好的问候,
我想显示所有类别(包括名称,说明等详细信息)及其产品(包含名称,价格,添加到购物车选项等)。 )在magento的单个页面上。如何在magento的单个页面上显示所有类别及其产品
请建议,如何做到这一点?
在此先感谢!
最好的问候,
$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>';
}
}
要获得所有产品:
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*');
foreach ($collection as $product) {
echo $product->getName() . "<br />";
}
link它是从哪里
复制,并得到所有的类别:
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*');
link从复制
这个问题不够具体。你遇到什么问题? – 2011-12-15 10:54:33