我确实遇到了问题,我想在网站上列出商店的CMS页面。当我得到这样的收藏时:
$collection = Mage::getModel('cms/page')->getCollection()->addStoreFilter($storeId)->addFieldToFilter('is_active',1);
我得到了所有页面,其中“All StoreViews”也作为设置商店。这有点显而易见,因为它们也适用于那个特定的商店。问题是,我只想获取针对特定商店的页面。
有什么想法吗?
答案 0 :(得分:4)
哦,我随机找到了解决方案。方法addStoreFilter()有第二个参数。如果将其设置为false,则只返回我想要的页面。也许是别人的暗示!
答案 1 :(得分:0)
试试此代码
$cmsPage = Mage::getModel('cms/page')->setStore(Mage::app()->getStore()->getId())->getCollection()->addFieldToFilter('is_active',1);
可能会帮到你!