Mar
01

Magento get skin url in static block

//get skin url in static block, same as http://example.com/skin/frontend/default/default/

{{skin url}}

e.g.: <img src=”{{skin url}}images/logo.gif” alt=”" />

Mar
01

Magento get skin url in template file

// get skin url in template file, same as http://example.com/skin/frontend/default/default/

<?php echo $this->getSkinUrl(); ?>
or
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); ?>

Mar
01

Magento get media url in static block

//get media url in static block, same as http://example.com/media/

{{media url}}

e.g.: <img src=”{{media url}}images/banner.gif” alt=”" />

Mar
01

Magento get media url in template file

// get media url in template file, same as http://example.com/media/

<?php echo $this->getMediaUrl(); ?>
or
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>

Mar
01

Magento get store url in static block

//get store url in static block, same as http://example.com/
{{store url}}
e.g.: <a href=”{{store url}}”>Home</a>

Feb
28

Magento get base url

// get base url in template file, same as http://example.com/

<?php echo $this->getBaseUrl(); ?>
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>

Feb
27

Mobilize Your Magento Store

In the Magento Admin area where you set your Design Package, you can also set an “Exception”. This will look for matched user agents and use the stated theme instead of the default theme. So you can set an “Exception” for smartphone customers.

Magento has a original mobile theme, defaul/iphone. We can set it as a mobile theme though it is rather unuseful.

1. Login to the admin area

2. Go to System > Configuration > General > Design -> Theme sections

3. Click ‘Add Exception’

4. Enter below text in matched expression

iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini

and in value enter ‘iphone’

5. Click Save Configuration

6. Use any smartphones or tablets, such as iPhone, iPod, Android, BlackBerry or Windows Phone test your work.

Jan
16

Magento get recently viewed products

1.Place code snippet below in any template u want to add

<?php echo $this->getLayout()->createBlock(‘reports/product_viewed’)->setTemplate(‘reports/product_viewed.phtml’)->toHtml(); ?>

2.Place code snippet below in any Backend cms-> page or static block

{{block type=”reports/product_viewed” template=”reports/product_viewed.phtml”}}

Replace template name, product_viewed.phtml with your site using.

Jan
04

Magento category page list subcategories products respectively

<?php
//Magento category page list subcategories products respectively

$_category = Mage::registry(‘current_category’);

$_children = explode(‘,’, $_category->getChildren());

$visibility = array(
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
);
foreach($_children as $childId) {
$_childCategory = Mage::getModel(‘catalog/category’)->load($childId);
//$_collection = Mage::getModel(‘catalog/product’)->getCollection();
$_collection = Mage::getResourceModel(‘catalog/product_collection’);
$_collection->addAttributeToFilter(‘visibility’, $visibility)
->addCategoryFilter($_childCategory)
->addAttributeToSelect(‘*’)
->setOrder(‘news_from_date’, ‘desc’)
->getSelect()
->limit(4);

echo $_childCategory->getName();//something html

if(count($_collection)) {
foreach ($_collection as $_product) {

echo $_product->getName();//something html

}
}
}

?>

Jan
03

Magento get category description

<?php

$_description = $_category->getDescription();
echo $_category->getDescription();

?>

Older posts «