Magento – Get all stores

Here is how to get all stores of your Magento instance a an Array: <?php $aAllStores = Mage::app()->getStores(); foreach ($aAllStores as $iStoreId => $oVal){ $sStoreCode = Mage::app()->getStore($iStoreId)->getCode(); $sStoreName = Mage::app()->getStore($iStoreId)->getName(); $iStoreId = Mage::app()->getStore($iStoreId)->getId(); echo $sStoreCode; echo $sStoreName; echo $iStoreId; } ?> To include the admin store you can call getStores like that: $aAllStores = Mage::app()->getStores(true) […]

Useful database queries

Move products to an another category UPDATE db220385_2.catalog_category_product SET category_id = 18 WHERE category_id = 19; Get all attribute option values The following example shows, how to get all available values for the attribute filter_stores SELECT ea.attribute_code, eao.option_id, eaov.store_id, eaov.value_id, eaov.value FROM eav_attribute AS ea INNER JOIN eav_attribute_option AS eao ON ea.attribute_id = eao.attribute_id INNER […]

Add link to header navigation

The following code inserts a link for extended search into the headers top link navigation <reference name=”top.links”> <action method=”addLink”> <label>Advanced Search</label> <url>catalogsearch/advanced</url> <title>Advanced Search</title> <prepare>false</prepare> <urlParams></urlParams> <position>6</position> </action> </reference> It is really important, that all sub elements of  the action tag are in the exact this order as the corresponding parameters of the underlaying method Mage_Page_Block_Template_Links:: […]

Get URL parameters

With the following function you can read out the parameters from the currently opened URL: function getUrlparam (param) { var search = window.location.search.substring(1); if(search.indexOf(‘&’) > -1) { var params = search.split(‘&’); for(var i = 0; i < params.length; i++) { var key_value = params[i].split(‘=’); if(key_value[0] == param) return key_value[1]; } } else { var params […]