Dali
Dali

Reputation: 7882

Magento - Select the cms pages of the current store

I use this collecion to select the cms pages

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

How can I change it to select only the cms pages of the current store ?

Thanks a lot

Upvotes: 1

Views: 5935

Answers (2)

ThreeCheeseHigh
ThreeCheeseHigh

Reputation: 1498

If you do not need filters try this:

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

Upvotes: 2

Sylvain Rayé
Sylvain Rayé

Reputation: 2466

Check the code below: ->addStoreFilter($store,$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'))));

Upvotes: 3

Related Questions