博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
首页的分类导购功能
阅读量:4200 次
发布时间:2019-05-26

本文共 1202 字,大约阅读时间需要 4 分钟。

首页的分类导购功能 代码如下:

$ids为catelog  数组

 

<div class="tan_tt">

<?php
$ids = array(82,18,37);
foreach($ids as $id){
    
$category = Mage::getModel('catalog/category')->load($id);
//$layer = Mage::getSingleton('catalog/layer');
//$category = $layer->getCurrentCategory();
$_category  = $category;
   // $_imgHtml   = '';
    $_imgUrl = $_category->getImageUrl();
    echo '<div class="tan_s"><a href="'.$_category->getUrl().'"><img style="width:55px;height:55px;" src="'.$_imgUrl.'" /></a></div>';
    echo '<div class="tan_gg"><a href="'.$_category->getUrl().'">'.$_category->getName().'</a></div>';
    echo "<div class='tan_yy'>";
    if($category->hasChildren()) {
    $ids = $category->getChildren();
    $subCategories = Mage::getModel('catalog/category')->getCollection();
    $subCategories->getSelect()->where("e.entity_id in ($ids)");
    $subCategories->addAttributeToSelect('name');
    $subCategories->load();   
    $jj = 1;
    foreach ($subCategories AS $item) {
        if($jj>6){ break; }
        echo " - " ;
        echo '<a href="'. $item->getUrl() . '">';
        echo $item->getName();
        echo "</a>(";
        echo $item->getProductCount();
        //echo $item->getChildrenCount();
        echo ")";
        echo "<br/>";
        $jj++;
    }
    echo " - <a href='". $_category->getUrl() . "'>More</a>";
    }
    echo "</div>";
}
?>
</div>

 

转载地址:http://bccli.baihongyu.com/

你可能感兴趣的文章
同步与异步的区别
查看>>
IT行业--简历模板及就业秘籍
查看>>
JNI简介及实例
查看>>
DOM4J使用教程
查看>>
JAVA实现文件树
查看>>
Drools 规则引擎
查看>>
OLTP和OLAP区别
查看>>
JMeter最常用的三种类型的压力测试
查看>>
Hibernate HQL 语法大全(上)
查看>>
深入Java事务的原理与应用
查看>>
CSS单位和CSS默认值大全
查看>>
交大我来了--周末再见了
查看>>
网页中flash wmode属性
查看>>
挑战自我,勇攀高峰
查看>>
神奇的HTML5画图应用
查看>>
flex 滚动条问题
查看>>
软件开发管理中的博奕论
查看>>
计算机认证考试种类
查看>>
SQL in和exists 比较
查看>>
社会性网络服务(SNS)研究
查看>>