2011-12-15 2 views

答えて

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>'; 
    } 
} 
0

すべての製品を取得するには:それは

からコピーされ

$collection = Mage::getModel('catalog/product') 
         ->getCollection() 
         ->addAttributeToSelect('*'); 

foreach ($collection as $product) { 
    echo $product->getName() . "<br />"; 
} 

linkをし、すべてのカテゴリを取得するには:から

$categories = Mage::getModel('catalog/category') 
        ->getCollection() 
        ->addAttributeToSelect('*'); 

linkをコピー

関連する問題