I am working on "Multistore functionality for my custome module". I refered core Cms page module. I found code

below in page resource module(Mage_Cms_Model_Resource_Page).

protected function _afterSave(Mage_Core_Model_Abstract $object)
    $oldStores = $this->lookupStoreIds($object->getId());
    $newStores = (array)$object->getStores();
    if (empty($newStores)) {
        $newStores = (array)$object->getStoreId();
    $table  = $this->getTable('cms/page_store');
    $insert = array_diff($newStores, $oldStores);
    $delete = array_diff($oldStores, $newStores);

    if ($delete) {
        $where = array(
            'page_id = ?'     => (int) $object->getId(),
            'store_id IN (?)' => $delete

        $this->_getWriteAdapter()->delete($table, $where);

    if ($insert) {
        $data = array();

        foreach ($insert as $storeId) {
            $data[] = array(
                'page_id'  => (int) $object->getId(),
                'store_id' => (int) $storeId

        $this->_getWriteAdapter()->insertMultiple($table, $data);

    //Mark layout cache as invalidated

    return parent::_afterSave($object);

what below code is doing?


Is this necessary ?


As you may suspect the line in question invalidates the layout cache.
This is needed in case you added something to the Layout Update XML or Custom Layout Update XML fields.
I agree that this could be done in a graceful way, bu checking first if something changed in those fields.
But I guess no one bothered to check.
But for sure this is needed.

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.