Snippets with the tag: store

Get store contact number

Description

Displays the store contact phone number

Code

Mage::getStoreConfig('general/store_information/phone');

Set current store

Description

Set current store passing the integer id

Code

$storeId = 1;
Mage::app()->setCurrentStore($storeId);

Check if RSS is enabled

Description

Check if RSS is enabled

Code

Mage::getStoreConfig('rss/catalog/category');

Number of products in the sidebar

Description

Get the number of products shown in the sidebar.

Code

Mage::getStoreConfig('checkout/sidebar/count');

Check request from frontend or backend

Description

Check whether request is coming from frontend or backend.

Code

if(Mage::app()->getStore()->isAdmin() && Mage::getDesign()->getArea() == 'adminhtml'){
        //request is from backend/admin
} else {
        //request is NOT from backend/admin
}

Get currency symbol

Description

Get currency symbol

Code

Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();

Get currency code

Description

Get currency code

Code

Mage::app()->getStore()->getCurrentCurrencyCode();

Convert price from current currency to base currency and vice-versa

Description

Convert price from current currency to base currency and vice-versa

Code

$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
$price = 150;

// convert price from current currency to base currency
$priceOne = Mage::helper('directory')->currencyConvert($price, $currentCurrencyCode, $baseCurrencyCode); 

// convert price from base currency to current currency
$priceTwo = Mage::helper('directory')->currencyConvert($price, $baseCurrencyCode, $currentCurrencyCode);

Using magento outside magento

Description

Using magento functions outside magento

Code

require_once 'app/Mage.php';
Mage::app($yourStoreCode);
echo Mage::getStoreConfig('general/store_information/name');

Changing the admin theme

Description

Changing the admin theme in local xml

Code


    
        
            
                 
                     yourtheme
                 
            
        
    

Display store contact name and email

Description

Display store contact name and email

Code

// General Contact
$name =  Mage::getStoreConfig('trans_email/ident_general/name'); 
$email = Mage::getStoreConfig('trans_email/ident_general/email');

// Sales Representative
$name =  Mage::getStoreConfig('trans_email/ident_sales/name'); 
$email = Mage::getStoreConfig('trans_email/ident_sales/email');

// Customer Support
$name =  Mage::getStoreConfig('trans_email/ident_support/name'); 
$email = Mage::getStoreConfig('trans_email/ident_support/email');

// Custom Email 1
$name =  Mage::getStoreConfig('trans_email/ident_custom1/name'); 
$email = Mage::getStoreConfig('trans_email/ident_custom1/email');

// Custom Email 2
$name =  Mage::getStoreConfig('trans_email/ident_custom2/name'); 
$email = Mage::getStoreConfig('trans_email/ident_custom2/email');