1

I need to update one cms page, but I have the same identifier 'home' for three pages in different stores. How can I update one page with need store.

My script has error: 'A page URL key for specified store already exists.';

Mage::app();
$cmsPage = Mage::getModel('cms/page')->setStore('need store')->load('home', 'identifier');
    try {
        $cmsPage->setRootTemplate('one_column');
    } catch (Exception $ex) {
        echo $ex->getMessage();
      }
$cmsPage->save();
Mage::app()->cleanCache();

1 Answer 1

0

The problem is that load() does not care about the store id you set before, it just loads the first page it can find with the "home" identifier.

You can use checkIdentifier() to retrieve the page ID for a given identifier and store, then load the page by id:

$pageId = Mage::getModel('cms/page')->checkIdentifier('home', $storeId);
$page = Mage::getModel('cms/page')->load($pageId);

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.