我试图在Magento 1.9.1中制作自定义类别列表 我的问题是,当我试图获取类别的Url并且我尝试输入类别时出现错误
WHOOPS, OUR BAD...
The page you requested was not found, and we have a fine guess why...()
这是代码:
<?php
$parent = Mage::getModel('catalog/category')->load(13);
$childrenCollection = $parent->getCollection();
$childrenCollection->addIdFilter($parent->getChildren());
$childrenCollection->addAttributeToFilter('is_active', 1);
$childrenCollection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('all_children')
->addAttributeToSelect('is_anchor')
->setOrder('position', Varien_Db_Select::SQL_ASC)
->joinUrlRewrite();
$childrenCollection->addAttributeToSelect('image');
?>
<ul>
<?php foreach($childrenCollection as $cat): ?>
<li>
<!-- FIRST METHOD-->
<a href="<?php echo $cat->getUrlKey(); ?>.html" title="<?php echo $cat->getName(); ?>">
//RETURNS http://localhost/projectname/index.php/product-name.html
<img class="cat-image" src="<?php echo $cat->getImageUrl(); ?>" />
</a>
<!-- SECOND METHOD-->
<a href="<?php echo $cat->getURL(); ?>.html" title="<?php echo $cat->getName(); ?>">
//RETURNS http://localhost/projectname/index.php/catalog/category/view/s/product-name/id/14/
<img class="cat-image" src="<?php echo $cat->getImageUrl(); ?>" />
</a>
</li>
<?php endforeach; ?>
</ul>
感谢所有建议,最好的问候