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