Deleting website in Magento gives page not found error
-
16-10-2019 - |
Pergunta
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?
Solução 2
I think I got it. First of all I did backup my DB so thanks @Marius :) After a lot of re-install DB and various trials I found out that the trick is the code of the default website. After I changed my website to default I deleted Magento's own Main Website
and changed the code of my site to base
since it's what is given by Magento to the main website. Then I ran my store once and after the value has been saved in DB and everything was working fine I again changed the code of my default site to its original from base. Turns out keeping 'base' as code is needed only once to set up all the values in the related tables.
Thanks everyone for helping me in the right direction. :)
Outras dicas
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.