php 多类别过滤器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 多类别过滤器相关的知识,希望对你有一定的参考价值。
<?php
$nav_class = new Mage_Catalog_Block_Navigation;
$cur_category = Mage::getModel('catalog/category')->load(Mage::registry('current_category')->getParentId());
$categories = array();
if(method_exists($cur_category, 'getChildrenCategories')){
$childrens = $cur_category->getChildrenCategories();
}
else{
$childrens = $cur_category->getChildren();
}
if($childrens && $childrens->count()){
foreach ($childrens as $children){
if($children->getIsActive()){
$children_category = Mage::getModel('catalog/category')->load($children->getId());
$categorytype = $children_category->getResource()->getAttribute('type_of_category')->getFrontend()->getValue($children_category);
if(!empty($categorytype) && strtolower($categorytype) == $_GET['categorygroup']){
$categories[] = $children->getId();
}
}
}
}
if(!empty($categories)){
$products = mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->joinField('category_id',
'catalog/category_product',
'category_id',
'product_id=entity_id',
null,
'left')
->addAttributeToFilter('category_id', array('in' => $categories));
$products->getSelect()->group('e.entity_id');
}
if(count($products)) :
?>
<div class="menu-category-products">
<ul class="products-grid">
<?php foreach ( $products as $productModel ) : ++$counter; $_product = Mage::getModel('catalog/product')->load($productModel->getId()); ?>
<li class="item"><h2 class="product-name">
<a href="<?php echo $_product->getProductUrl() ?>">
<?php if($_product->getmenutitle()){ echo $_product->getmenutitle();}else{ echo $this->htmlEscape($_product->getName()); } ?>
</a></h2></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
以上是关于php 多类别过滤器的主要内容,如果未能解决你的问题,请参考以下文章
php 类别重命名类别类别过滤器
使用 PHP 按类别过滤帖子
php WordPress |类别过滤器下拉列表
PHP MySQL搜索/类别过滤器
php magento 2按根类别添加过滤器
php magento 2按根类别添加过滤器