Have two pages where i wanna update the content, both with the identifier 'home', one is on default(0) and the other is on store german(2).

If i do the following iteration, i get the correct pages but save() tries to save a new page what causes an exception. What's wrong or what can i change?

$oMagePageModel = Mage::getModel('cms/page');
foreach ($aHomePageTeaserContent as $iStoreId => $sHomePageTeaserContent) {
  $oMagePageModel->load('home', 'identifier');

  $sHomePagePrevContent = $oMagePageModel->getContent();
  $oMagePageModel->setContent($sHomePagePrevContent . $sHomePageTeaserContent);


  • I'm guessing this has something to do with EE's CMS page version controls. – benmarks Jul 29 '15 at 17:36
  • Version control isn't activated for that page, should be only a problem if active or? And the error i receive would be weird then: "A page URL key for specified store already exists." – Tobias Hartmann Jul 30 '15 at 8:39

Found the answer to it, first i thought loading by id could help so i changed the script to:

$oMagePageModel = Mage::getModel('cms/page');

foreach ($aHomePageTeaserContent as $iStoreId => $sHomePageTeaserContent) {
  $iPageId = $oMagePageModel->checkIdentifier('home', $iStoreId);
  $oPage   = $oMagePageModel->load($iPageId);

  $sPagePrevContent = $oPage->getContent();
  $oPage->setContent($sPagePrevContent . $sHomePageTeaserContent)->save();


what looked much nicer to me but didn't work, too. After diggin deeper into the rabbit hole i saw, that Mage_Cms_Model_Resource_Page getIsUniquePageToStores() is the point where it comes to the problem.

In the first lines of the Method it checks $object->hasStores() and if the object as no stores, it sets it to Mage_Core_Model_App::ADMIN_STORE_ID what exactly happens to my pages and trying to overwrite that page fires the exception.

So the weird solution, since i load the page by storeId and storeId is available in the page object, is setting the stores again with $oPage->setData('stores', array($iStoreId)); before saving the page.

| improve this answer | |

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.