仅列出magento中所有商店中具有类别缩略图的活动根类别
我在magento网站上有5家店铺 我想列出所有商店的所有根目录及其缩略图,并将缩略图链接到商店的主页 例如:仅列出magento中所有商店中具有类别缩略图的活动根类别,magento,categories,Magento,Categories,我在magento网站上有5家店铺 我想列出所有商店的所有根目录及其缩略图,并将缩略图链接到商店的主页 例如: WEBSITE: store1 -> category1 store2 -> category2 store3 -> category3 我已经让代码工作了,但是我不能使用addAttributeToFilter(),这样我只能列出那些活动的类别。当前,以下代码显示所有根类别(无论是否活动) <?php $groups = $this->
WEBSITE:
store1 -> category1
store2 -> category2
store3 -> category3
我已经让代码工作了,但是我不能使用addAttributeToFilter(),这样我只能列出那些活动的类别。当前,以下代码显示所有根类别(无论是否活动)
<?php
$groups = $this->getGroups();
$cnt = count($groups);
?>
<?php if($cnt > 1): ?>
<div class="container">
<?php foreach ($groups as $_group): ?>
<?php
$storeId = $_group->getId();
$store_url = Mage::app()->getStore($storeId)->getHomeUrl();
$root_cat = Mage::app()->getStore($storeId)->getRootCategoryId();
$category_model = Mage::getModel('catalog/category')->load($root_cat); // here I used addAttributeToFilter() and gave me error
$_category = $category_model;
$_img_path = Mage::getBaseUrl('media').'catalog/category/';
$_no_of_columns = ($this->no_of_columns) ? $this->no_of_columns : 6;
?>
<?php if ($_i++ % $_no_of_columns == 0): ?>
<div class="row slide">
<?php endif; ?>
<?php if ($_imgUrl = $_category->getThumbnail()): ?>
<div class="span2">
<a href="<?php echo $store_url ?>" title="<?php echo $_category->getName(); ?>">
<img class="img-polaroid" src="<?php echo $_img_path.$_imgUrl; ?>" />
</a>
<h6>
<a href="<?php echo $store_url; ?>" title="<?php echo $_category->getName(); ?>">
<?php echo $_category->getName(); ?>
</a>
</h6>
</div>
<?php endif; ?>
<?php if ($_i % $_no_of_columns == 0 || $_i == $_cat_count): ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
您的代码使用的是类别模型,而不是类别集合。模型表示一个实体,没有任何过滤器。通过load()
加载模型,您正在将所有数据应用于实例,因此您应该能够调用$category\u model->getIsActive()
来确定活动标志是否(0)还是是(1)。根类别还是“顶级类别”?无需呼喊。$this
是哪一类?非常感谢!它起作用了;但是当我使用$category\u model->getIsActive()时,我不得不使用($\u category->getIsActive())
代码>,它给了我一个错误。如果要按自定义属性筛选类别,该怎么办?我不知道为什么要用这美元。这不是我的密码。我从其他来源取材。我做了$groups=Mage::app()->getStores()代码>你的注意力集中/工作在Magento的一小部分中-你应该花一些时间完成这个任务。有很多东西要学。