从后端获取Magento Mage_Core _Model_Store_Group到前端阵列


Get Magento Mage_Core_Model_Store_Group from backend into frontend array

如何将Mage_Core _Model_Store_Group对象的属性获取到数组中?我需要将_storeIds和_storeCodes分别放入相应的数组中。

$theobjectthathasdataiwant = Mage::getSingleton('adminhtml/system_store')->getGroupCollection();
var_dump($theobjectthathasdataiwant);

结果在:

object(Mage_Core_Model_Store_Group)[129]
protected '_cacheTag' => boolean true
protected '_eventPrefix' => string 'store_group' (length=11)
protected '_eventObject' => string 'store_group' (length=11)
protected '_stores' => 
array (size=3)
  7 =>
   .....
protected '_storeIds' => 
array (size=3)
  7 => string '7' (length=1)
  4 => string '4' (length=1)
  5 => string '5' (length=1)
protected '_storeCodes' => 
array (size=3)
  7 => string 'rg' (length=2)
  4 => string 'xray' (length=4)
  5 => string 'zoe' (length=3)
protected '_storesCount' => int 3

提前谢谢!

明白了!如下:

$theobjectthathasdataiwant = Mage::getSingleton('adminhtml/system_store')->getGroupCollection();
$Group = $theobjectthathasdataiwant[5]; //<-- [5] is the group of my desired store array
$storearrayiwant = $Group->getStoreIds();
$var_dump($storearrayiwant);

最后,我的商店id数组:

array (size=3)
  7 => string '7' (length=1)
  4 => string '4' (length=1)
  5 => string '5' (length=1)