Magento - 选择当前商店的cms页面

时间:2011-10-18 10:20:39

标签: magento

我用这个集合来选择cms页面

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

如何更改它以选择当前商店的cms页面?

非常感谢

2 个答案:

答案 0 :(得分:3)

检查以下代码: - > 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'))));

答案 1 :(得分:2)

如果您不需要过滤器,请尝试以下方法:

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