4

I have two store views, for 2 languages. I have a page 'foo' defined in both languages (i.e. store views). I'm using

$aCmsPage = Mage::getModel('cms/page')->load('foo', 'identifier');

However, I always get the page in the same language.

Shouldn't I get the page for the current store view?

What am I doing wrong?

3 Answers 3

10

You can use below code:

$identifier='foo';
    $page   = Mage::getModel('cms/page');
            $pageId = $page->checkIdentifier($identifier, Mage::app()->getStore()->getId());
            if ($pageId) {
               aCmsPage = Mage::getModel('cms/page')->load($pageId);
            }
1
  • You, Sir, are a genius! Commented Jun 13, 2015 at 11:46
1

you have to set store id in call like

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

so it will load cms page per current store.

hope this will sure work for you.

2
  • Did not work ;( Any other ideas? Commented Jun 13, 2015 at 8:12
  • Second that - using setStore does not work
    – Alan A
    Commented Jan 24, 2019 at 15:39
1

You can use helper class Mage_Cms_Helper_Page's method getPageUrl, it gives the result of cms page URL with the correct store view

Mage::helper('cms/page')->getPageUrl($pageid);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.