Get all store API magento

Get all store API magento
Get all store API magento

<?php
error_reporting(0);
include("../app/Mage.php");
umask(0);
Mage::app();
$result_array = array();
$result_array_group = array();
$result_array_store = array();
$result_array1=array();
foreach (Mage::app()->getWebsites() as $website) {
$result_array["website_name"]=array("website_id"=>$website->getId() ,"website_name"=>$website->getName());
$result_array["website_group"]=array();
$result_array["website_store"]=array();
foreach ($website->getGroups() as $group) {
$result_array_group["group_id"]=$group->getId();
$result_array_group["group_name"]=$group->getName();
array_push($result_array["website_group"], $result_array_group);
$stores = $group->getStores();
foreach ($stores as $store) {
$result_array_store["store_id"]=$store->getId();
$result_array_store["store_code"]=$store->getCode();
$result_array_store["store_name"]=$store->getName();
array_push($result_array["website_store"], $result_array_store);
}
}
array_push($result_array1, $result_array);
}
echo json_encode($result_array1);
?>

No comments:

Powered by Blogger.