3

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?

8

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 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

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.

  • Did not work ;( Any other ideas? – Tero Lahtinen Jun 13 '15 at 8:12
  • Second that - using setStore does not work – Alan A Jan 24 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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