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?

  • Cache cleared? Reindexed? Jul 19, 2013 at 12:29
  • Yes. First I deleted from admin and when the error occurred I thought maybe it's not the way to go. So then I restored my DB and deleted entries directly from the DB table. First store views, then stores and then website.
    – jdhaar
    Jul 19, 2013 at 12:40
  • Sorry but I asked about Magneto caches and indexes. Jul 19, 2013 at 12:44
  • 1
    So you deleted the default website? Did you reconfigure and set another website as the default for that store? Is everything setup in Admin -> System -> Manage Stores, and defaults set?
    – ProxiBlue
    Jul 19, 2013 at 12:57
  • Yes. I first made a new website as default and then deleted the other website which wasn't default anymore.
    – jdhaar
    Jul 19, 2013 at 13:12

3 Answers 3


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')
    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.

  • I changed the id of the store to 1 and then deleted the default store and then changed the ids of store views to sync with the new store but it is a messy process and there is so much inter-connection. I am still getting the error.
    – jdhaar
    Jul 20, 2013 at 5:41

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. :)

  • Your self selected answer is not working for me. I don't know how just only changing the main website code your site started working? Actually Marius answer is correct direction. I will update my points as well. Oct 24, 2019 at 6:24

I am going to update my points here for My reference and for all those who want to achieve this task (removal of all website including main website having store code 1)

1) Delete all web sites except The one you want to keep from GUI (delete base site at the end)
2) Now delete base website you will have only one site left in DB which you want to keep.(after this everything collapse)
3) Run query: UPDATE `core_store` SET `store_id`='1' WHERE `store_id`='7';
(change reaming website's store code to 1 your front-end starts rendering )
4) For admin need to change urls in core_config_table
and that's it.

You may face few more issues or error depend upon your project you have to resolve it as well but main steps are same.

On delete website it will delete all of its data but even then you can verify it by running the following queries:

DELETE FROM catalog_product_entity WHERE entity_id NOT IN (SELECT product_id FROM catalog_product_website);
DELETE FROM catalogrule WHERE rule_id NOT IN (SELECT DISTINCT rule_id FROM catalogrule_website);
DELETE FROM salesrule WHERE (rule_id NOT IN (SELECT DISTINCT rule_id FROM salesrule_website));
DELETE FROM core_config_data WHERE (scope="stores" AND scope_id NOT IN (SELECT store_id FROM core_store)) OR (scope="websites" AND scope_id NOT IN (SELECT website_id FROM core_website));
DELETE FROM cms_page WHERE page_id NOT IN (SELECT DISTINCT page_id FROM cms_page_store);
DELETE FROM cms_block WHERE block_id NOT IN (SELECT DISTINCT block_id FROM cms_block_store);
DELETE FROM sales_flat_order WHERE store_id IS NULL

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.