2015-11-29 55 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)