$categories = Mage::getModel('catalog/category')->getCollection()
 ->addAttributeToSelect('id')
 ->addAttributeToSelect('name')
 ->addAttributeToSelect('url_key')
 ->addAttributeToSelect('url')
 ->addAttributeToSelect('is_active');
foreach ($categories as $category)
 {
 if ($category->getIsActive()) { // Only pull Active categories
 $entity_id = $category->getId();
 $name = $category->getName();
 $url_key = $category->getUrlKey();
 $url_path = $category->getUrl();
 }
 }
<?php // load(level-number)?>
 <?php $categoryIds = Mage::getModel('catalog/category')->load(3)->getChildren() ?>
 <?php $categoryIds = explode(',', $categoryIds); ?>
 <?php $count = count($categoryIds); $i=0; ?>
 <?php foreach ($categoryIds as $categoryId): ?>
 <?php $category = Mage::getModel("catalog/category")->load($categoryId) ?>
 <li<?php if (++$i == $count): ?> class="last"<?php endif ?>><a href="<?php echo $category->getUrl() ?>" title="<?php echo $this->stripTags($category->getName()) ?>"><?php echo $this->stripTags($category->getName()) ?></a></li>
 <?php endforeach ?>
 

$_categoryIds = $_product->getCategoryIds();

foreach ($_categoryIds as $_categoryId) { $_category = Mage::getModel('catalog/category')->load($_categoryId);

$_category_name = $_category->getName(); $_category_url = $_category->getUrlPath();

break;

}

 

 

标签: Magento

评论已关闭