对于多域名,多网店,我们想产看一下当前magento网店的website和store,这就要使用到magento的collection,故,需要把magento的所有的website和store调用出来,供使用,下面是一个得到webisite和store的collection,然后遍历出来的程序代码!希望有此需求的时候对您有所帮助

<?php

2require_once('app/Mage.php');
3Mage::app();
4?>
5 
6<h2>Websites</h2>
7<?php
8 
9$websites = Mage::getModel('core/website')
10          ->getCollection();
11 
12foreach($websites as $website) {
13$website_data = $website->getData(); ?>
14<h3><?php echo $website->getName(); ?></h3>
15<table>
16  <?php foreach($website_data as $key => $item) { ?>
17  <tr>
18    <td><?php echo $key; ?></td>
19    <td><?php echo $item; ?></td>
20  </tr>
21  <?php  } ?>
22</table>
23<?php } ?>
24 
25<h2>Stores</h2>
26<?php
27 
28$stores = Mage::getModel('core/store')
29          ->getCollection();
30 
31foreach($stores as $store) {
32$store_data = $store->getData(); ?>
33<h3><?php echo $store->getName(); ?></h3>
34<table>
35  <?php foreach($store_data as $key => $item) { ?>
36  <tr>
37    <td><?php echo $key; ?></td>
38    <td><?php echo $item; ?></td>
39  </tr>
40  <?php  } ?>
41</table>
42<?php } ?>