博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一段分类代码--产品分类的!
阅读量:4200 次
发布时间:2019-05-26

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

<?php

02    $c=Mage::getModel('catalog/category');

//根据属性得到一个模型集合。

03    $pc=$c->loadByAttribute('name','选购礼盒');
04    if($pc->hasChildren()) {
05    $ids = $pc->getChildren();

//得到所有产品的分类集合。

06    $subCategories = Mage::getModel('catalog/category')->getCollection();

//使用getSelect()方法和where() 方法重新选取。

07    $subCategories->getSelect()->where("e.entity_id in ($ids)");
08    $subCategories->addAttributeToSelect('*');
09    $subCategories->load();
10    }
11    ?>

 

 

 

 

 

 

layout中的标签<cms_page_read>就是当weburl/cms/page/read  为访问路径的时候加载的layout handle,layout为默认的!!好强大,今晚让我想出来了!!

//装载缓存。
$this->loadLayout();   
//得到block实例。
$block=Mage::getBlockSingleton('profile/profile');
//load profile
//$block->getProfile()----------Return a collection of profiles.        
$profile = $block->getProfile();
        if($profile) {
//操作layout中的参数(通过方法),好灵活!!
             $this->getLayout()->getBlock('head')->setTitle($profile->getData("content_heading"))
                ->setDescription($profile->getData("meta_description"))
                ->setKeywords($profile->getData("meta_keywords"));
        }
//画出来!!
        $this->renderLayout();
//Return a collection of profiles.
public function getProfiles($category_id) {
        $profiles = Mage::getModel('profile/profile')->getCollection()
//下面的在细细研究!!
            ->addStoreFilter(Mage::app()->getStore()->getId());
        $profiles->addFieldToFilter('category_id', $category_id);
        $profiles->setOrder("creation_time", "DESC");
        return $profiles;
    }

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

你可能感兴趣的文章
Debian 系统时间
查看>>
COM对象的标识——CLSID
查看>>
COM接口定义和标识
查看>>
接口内存模型
查看>>
C# TextBox中的Validating与Validated事件
查看>>
关于Platform SDK和Windows SDK
查看>>
初始化列表
查看>>
条款15:让operator=返回*this的引用
查看>>
装箱和拆箱数据类型转换
查看>>
MFC 消息映射的工作方式
查看>>
MFC项目Unicode版本程序入口
查看>>
精典FormsAuthenticationTicket分析
查看>>
asp.net form验证
查看>>
VS2008中安装ASP.NET MVC2后无法新建工程的解决方法
查看>>
SQL Server 标识列
查看>>
SQL WITH TIES
查看>>
ASP.NET调用存储过程并接收存储过程返回值
查看>>
Debian: Driver 'pcspkr' is already registered, aborting
查看>>
Samba
查看>>
JavaScript原型和继承
查看>>