2011-10-18 18 views
1

我用這個最愛的CMS頁面選擇CMS頁面Magento的 - 選擇目前店內

$collection = Mage::getModel('cms/page')->getCollection() 
     ->addFieldToFilter('is_active',1) 
     ->addFieldToFilter('identifier',array(array('nin'=>array('no-route','enable-cookies')))); 

我怎樣才能改變它來選擇目前店內的CMS頁面?

非常感謝

回答

3

檢查下面的代碼: - > addStoreFilter($商店$ withAdmin)

$collection = Mage::getModel('cms/page')->getCollection() 
       ->addStoreFilter($storeId)// You have to provide a store id or Mage_Core_Model_Store Object @see class Mage_Cms_Model_Mysql4_Page_Collection 
       ->addFieldToFilter('is_active',1) 
       ->addFieldToFilter('identifier',array(array('nin'=>array('no-route','enable-cookies')))); 
+0

謝謝很多;) – Bizboss

+0

你知道我該如何按標題排列結果? 我試過' - > addAttributeToSort('title','ASC');'但它不起作用! – Bizboss

+0

試試這個,但沒有測試: - > addOrder('title','ASC') –

2

如果您不需要過濾器試試這個:

$cmsPage = Mage::getModel('cms/page')->setStore(Mage::app()->getStore()->getId())->load('faq-and-help', 'identifier');