一段分类代码--产品分类的!

来源:互联网 发布:python十进制转二进制 编辑:程序博客网 时间:2024/04/30 01:58

<?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;
    }

原创粉丝点击