一段分類代碼–產品分類的!

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.