I am trying to delete multiple store views using a php script that includes app/Mage.php
in the root of my installation.
I am able to get the list of websites and store views but I need to somehow parse them into the delete()
method as an array the loop over each store_id
in order to delete the ones I no longer need.
Also, I need to find a way to filter the store_id
so that I don't remove the default store view or admin.
Here is what I have so far:
/** Load Magento **/
umask(0);
require_once 'app/Mage.php';
/** Load webstes and stores */
echo "Website ID: " . Mage::app()->getWebsite()->getId() . "<br/>";
echo "Website Name: " . Mage::app()->getWebsite()->getName() . "<br/>";
echo "Store ID: " . Mage::app()->getStore()->getId() . "<br/>";
echo "Store Name: ".Mage::app()->getStore()->getName(). "<br/>";
echo "Store code: ". Mage::app()->getStore()->getCode()."<br/>";
/** @var ** $website loop */
foreach (Mage::app()->getWebsites() as $website) {
foreach ($website->getGroups() as $group) {
$stores = $group->getStores();
foreach ($stores as $store) {
echo $store->getId() ." ".$store->getName()."<br/>";
}
}
}
/** ** End of script */
I'm haven't been able to find a way to call the delete()
method foreach store_id
using:
$model = Mage::getModel('core/store')->load($stores);
$model->delete();
Can anyone help?
Best Answer
use storeId instead of $stores
like
load function will load current store in for loop with $store->getId()
this is just pseudocode use should have to follow just checkout with detail code in mage library
hope this will work for you.