Fetch website information from Store and Group in Magento

Topics focus on Web Developments, Programming, Database, Digital Marketing Tutorials, Code Snippets, SEO, Social Media Marketing and Inspirational articles.

Fetch website information from Store and Group in Magento

Fetch website information from Store and Group in Magento

Here I explained How to fetch website information from Store and Group in Magento. You can use below code for fetching some data from one website to another website. Hope it will help you…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<? php
$store_id = 1; //your required store Id will go here
$store_model = Mage::getModel('core/store'); //store model
$store_group_model = Mage::getModel('core/store_group'); //store group model
$website_model = Mage::getModel('core/website'); //website model
$store_data =  $store_model->load($store_id); //load store object
$group_id = $store_data->getGroupId(); //get store group id from the store  
$website_id = $store_data->getWebsiteId();   //get website id from the store        
$website_id = $store_group_model->load($group_id)->getWebsiteId(); //get website id from the store group id      
$website_obj = $store_group_model->load($group_id)->getWebsite();//get website object
$group_ids = $website_obj->getGroupIds(); //get all group ids as array of the website
$stores = $store_model->getCollection()->addGroupFilter($group_id);   //get the stores from the existing store group
foreach ($stores as $_store):
    $store_ids[] = $_store->getId(); //get store id
endforeach;
$stores = $store_model->getCollection()->addWebsiteFilter($website_id); //get the stores from the existing website
foreach ($stores as $_store):
    $store_ids[] = $_store->getId();
endforeach;
$store_ids = $website_model->load($website_id)->getStoreIds(); //get the stores array from the website id
?>

Add comment


 

Pin It on Pinterest

Share This