Friday, February 7, 2014

Another way to get all stores names with their id in Magento


/**
 * Return all the stores
 * 
 * @author abelbm
 * @return array
 */
function getAllStores(){
    $stores = array();
    
    $storesData = Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(); 
    foreach ($storesData as $storeGrandParent)
        foreach ($storeGrandParent as $storeParent)
            if(is_array($storeParent) && !empty($storeParent)){
                foreach ($storeParent as $store)
                    $stores[$store['value']] = strip_tags(trim(iconv('UTF-8', 'ASCII//TRANSLIT', $store['label'])));
            }
            
    return $stores;
}

No comments:

Post a Comment