【问题标题】:Determine all stores for a CMS page in Magento?确定 Magento 中 CMS 页面的所有商店?
【发布时间】:2023-04-06 22:01:01
【问题描述】:

我确实有一个问题,我想在商店的网站上列出 CMS 页面。当我得到这样的收藏时:

$collection = Mage::getModel('cms/page')->getCollection()->addStoreFilter($storeId)->addFieldToFilter('is_active',1);

我得到了所有的页面,其中也有“所有 StoreViews”作为集合商店。这很明显,因为它们也适用于特定商店。问题是,我只想获取该特定商店的页面only

有什么想法吗?

【问题讨论】:

    标签: php magento store


    【解决方案1】:

    哦,我随机找到了解决方案。 addStoreFilter() 方法有第二个参数。如果将其设置为 false,它只会返回我想要获取的页面。也许是给别人的暗示!

    【讨论】:

      【解决方案2】:

      试试这个代码

      $cmsPage = Mage::getModel('cms/page')->setStore(Mage::app()->getStore()->getId())->getCollection()->addFieldToFilter('is_active',1);
      

      可能对你有帮助!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-07-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多