Magento – Deleting website in Magento gives page not found error

404-pagemagento-1.7multistorestore-view

I have multiple websites in a store. I want to delete two of them. Including the main website and its stores and store views. After I delete them when i try to access my site from the websites that are not deleted it displays page not found error. What could be the cause for it and how can I solve it?

Best Answer

You shouldn't delete the store with id 1.
In the method Mage_Code_Model_App::getStore there is this

if (!Mage::isInstalled() || $this->getUpdateMode()) {
   return $this->_getDefaultStore();
}

This means that when you are installing, or running upgrade scripts, the result of _getDefaultStore is used as a store.

_getDefaultStore() looks like this:

protected function _getDefaultStore()
{
    if (empty($this->_store)) {
        $this->_store = Mage::getModel('core/store')
            ->setId(self::DISTRO_STORE_ID)
            ->setCode(self::DISTRO_STORE_CODE);
    }
    return $this->_store;
} 

And since the constant DISTRO_STORE_ID is 1, this means that for installing and running upgrade scripts the store with ID 1 is used. Deleting it can cause malfunctions.
Try to change the id of a store view (the default one) to 1. The constraints on the tables should change it everywhere else. This process may take a while, so be patient. And back-up your database before trying it.

Related Topic