You can use the following line to get the current store object.
// Get the current store $store = Mage::app()->getStore();
The following is the data returned by getData() function of the $store object.
print_r( $store->getData() );
Array ( [store_id] => 1 [cod e] => wb_us_en [website_id] => 1 [group_id] => 1 [name] => English [sort_order] => 0 [is_active] => 1 [available_currency_codes] => Array ( [0] => USD ) [base_currency] => Mage_Directory_Model_Currency Object ( [_filter:protected] => [_rates:protected] => Array ( [USD] => 1 ) [_eventPrefix:protected] => core_abstract [_eventObject:protected] => object [_resourceName:protected] => directory/currency [_resource:protected] => [_resourceCollectionName:protected] => directory/currency_collection [_cacheTag:protected] => [_dataSaveAllowed:protected] => 1 [_isObjectNew:protected] => [_data:protected] => Array ( [currency_code] => USD ) [_hasDataChanges:protected] => 1 [_origData:protected] => [_idFieldName:protected] => [_isDeleted:protected] => [_oldFieldsMap:protected] => Array ( ) [_syncFieldsMap:protected] => Array ( ) ) [current_currency] => Mage_Directory_Model_Currency Object ( [_filter:protected] => [_rates:protected] => [_eventPrefix:protected] => core_abstract [_eventObject:protected] => object [_resourceName:protected] => directory/currency [_resource:protected] => [_resourceCollectionName:protected] => directory/currency_collection [_cacheTag:protected] => [_dataSaveAllowed:protected] => 1 [_isObjectNew:protected] => [_data:protected] => Array ( [currency_code] => USD ) [_hasDataChanges:protected] => 1 [_origData:protected] => [_idFieldName:protected] => [_isDeleted:protected] => [_oldFieldsMap:protected] => Array ( ) [_syncFieldsMap:protected] => Array ( ) ) )
Below is the sample code showing you how you can access the store data. Two ways have been provided below to access the same data, you can use any one of them.
//Get the current store id $storeId = $store->getData('store_id'); $storeId = $store->getStoreId()); //Get the current store code $storeCode = $store->getData('code'); $storeCode = $store->getCode(); //Get current website id $storeWebsiteId = $store->getData('website_id'); $storeWebsiteId = $store->getWebsiteId(); //Get current store group id $storeGroupId = $store->getData('group_id'); $storeGroupId = $store->getGroupId()); //Get the current store name $storeName = $store->getData('name'); $storeName = $store->getName(); //Get the current store sort order $storeSortOrder = $store->getData('sort_order'); $storeSortOrder = $store->getSortOrder(); //Get the current store status $storeStatus = $store->getData('is_active'); $storeStatus = $store->getIsActive(); //Get the current store available currency codes $storeAvailableCurrencyCodes = $store->getData('available_currency_codes'); $storeAvailableCurrencyCodes = $store->getAvailableCurrencyCodes(); //Get the current store base currency code $storeBaseCurrency = $store->getData('base_currency')->getCurrencyCode(); $storeBaseCurrency = $store->getBaseCurrency()->getCurrencyCode(); //Get the current store current currency code $storeCurrentCurrency = $store->getData('current_currency')->getCurrencyCode(); $storeCurrentCurrency = $store->getCurrentCurrency()->getCurrencyCode();
Here is the list of all functions all available in store object (Mage_Core_Model_Store), you can use these functions to access store related data.
print_r( get_class_methods($store) );
returns
Array ( [0] => getBaseUrl [1] => getStoreInUrl [2] => getId [3] => isAdmin [4] => isAdminUrlSecure [5] => isFrontUrlSecure [6] => isCurrentlySecure [7] => getBaseCurrencyCode [8] => getBaseCurrency [9] => getDefaultCurrencyCode [10] => getDefaultCurrency [11] => setCurrentCurrencyCode [12] => getCurrentCurrencyCode [13] => getAvailableCurrencyCodes [14] => getCurrentCurrency [15] => getCurrentCurrencyRate [16] => convertPrice [17] => roundPrice [18] => formatPrice [19] => getPriceFilter [20] => getRootCategoryId [21] => setGroup [22] => getGroup [23] => getWebsiteId [24] => getGroupId [25] => getDefaultGroupId [26] => isCanDelete [27] => getCurrentUrl [28] => getIsActive [29] => getName [30] => resetConfig [31] => isReadOnly [32] => getFrontendName [33] => load [34] => loadConfig [35] => getCode [36] => getConfig [37] => initConfigCache [38] => setConfig [39] => setWebsite [40] => getWebsite [41] => processSubst [42] => getDefaultBasePath [43] => getUrl [44] => getIdFieldName [45] => setId [46] => getResourceName [47] => getResourceCollection [48] => getCollection [49] => afterLoad [50] => save [51] => afterCommitCallback [52] => isObjectNew [53] => getCacheTags [54] => getCacheIdTags [55] => cleanModelCache [56] => delete [57] => getResource [58] => getEntityId [59] => clearInstance [60] => __construct [61] => isDeleted [62] => hasDataChanges [63] => setIdFieldName [64] => addData [65] => setData [66] => unsetData [67] => unsetOldData [68] => getData [69] => setDataUsingMethod [70] => getDataUsingMethod [71] => getDataSetDefault [72] => hasData [73] => __toArray [74] => toArray [75] => toXml [76] => toJson [77] => toString [78] => __call [79] => __get [80] => __set [81] => isEmpty [82] => serialize [83] => getOrigData [84] => setOrigData [85] => dataHasChangedFor [86] => setDataChanges [87] => debug [88] => offsetSet [89] => offsetExists [90] => offsetUnset [91] => offsetGet [92] => isDirty [93] => flagDirty )
Leave a Comment