2015-11-29 29 views
0

如何将Mage_Core_Model_Store_Group对象的属性获取到数组中?我需要将_storeIds和_storeCodes分别放入数组中。从后端获取Magento Mage_Core_Model_Store_Group到前端数组

$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 

预先感谢您!

回答

0

Got it!具体如下:

$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)