Showing posts with label Magento Paths. Show all posts
Showing posts with label Magento Paths. Show all posts

Sunday, July 8, 2012

how to check home page in magento?

if(Mage::getSingleton('cms/page')->getIdentifier() == 'home' &&Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' )

How to define custom layout in magento like 1column,2-column right,3-columns


template/page/2columns-aboutus.phtml
-----------------------------------------------------------------------
layout/page.xml
-----------------------------------------------------------------------
find All Two-Column Layout Pages (Left Column) and place
-----------------------------------------------------------------------
<page_two_columns_aboutus translate="label">
<label>All Two-Column Layout Pages (About us Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-aboutus.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_aboutus>
-----------------------------------------------------------------------
now define global object in xml
app/code/local/companyname/modulename/etc/config.xml
<two_columns_aboutus module="page" translate="label">
<label>2 columns with About Us</label>
<template>page/2columns-aboutus.phtml</template>
<layout_handle>page_two_columns_aboutus</layout_handle>
</two_columns_aboutus>
Now go to admin login pages/ -----> 2 columns with About Us

How to define store path on backend side while create static block

{{store url='company-history'}}

How to get request on magento?

echo $this->getRequest()->getParams())

How to get cms page title in magento?

$pageTitle = Mage::getSingleton('cms/page')->getTitle();

How to get product details from product id in magento?

$model = Mage::getModel('catalog/product');
$_product = $model->load($productId);
echo $_product->getShortDescription();
echo $_product->getDescription();
echo $_product->getName();
echo $_product->getPrice();
echo $_product->getSpecialPrice();
echo $_product->getProductUrl();
echo $_product->getImageUrl();
echo $_product->getSmallImageUrl();
echo $_product->getThumbnailUrl();

How to get category details from category id on magento?

$category = Mage::getModel('catalog/category')->load($_category);
echo $category->getUrl();// category url
echo $category->getName();
echo $category->getImageUrl();
$categoryImage = $category->getImage();

Custom 'Sort by' drop-down menu options Lowest price, Higest price, Name A-Z, Name Z-A, Newest to Oldest & Oldest to Newest in magento


View following url
http://magento-talks.blogspot.in/2011/08/custom-sort-by-drop-down-menu-options.html

Magento all paths.


Mage::getBaseUrl() => Gets base url path e.g. http://my.website.com/
Mage::getBaseUrl(‘media’) => Gets MEDIA folder path e.g. http://my.website.com/media/
Mage::getBaseUrl(‘js’)                => Gets JS folder path e.g. http://my.website.com/js/
Mage::getBaseUrl(‘skin’)              => Gets SKIN folder path e.g. http://my.website.com/skin/
Mage::getBaseDir()             => Gives you your Magento installation folder / root folder e.g. /home/kalpesh/
Mage::getBaseDir(‘app’)             => Gives you your Magento’s APP directory file location e.g. /home/kalpesh/
Mage::getBaseDir(‘design’)            => Gives you your Magento’s DESIGN directory file location e.g. /home/kalpesh/wo
Mage::getBaseDir(‘media’) => Gives MEDIA directory file path
Mage::getBaseDir(‘code’) => Gives CODE directory file path
Mage::getBaseDir(‘lib’) => Gives LIB directory file path
Get Current URL – whole URL path
Mage::helper(‘core/url’)->getCurrentUrl()

How to change default image white space(background) on magento?

app/code/core/mage/catalog/model/Product/image.php

How to display product price with currency on magento?

$formattedPrice = Mage::helper('core')->currency($objProduct->getPrice(),true,false);

How to change default image white space(background) on magento?

app/code/core/mage/catalog/model/Product/image.php

How to display product price with currency on magento?

$formattedPrice = Mage::helper('core')->currency($objProduct->getPrice(),true,false);

How to get products available stock quantity in magento?

echo $qtyStock = (int) Mage::getModel('cataloginventory/stock_item') ->loadByProduct($_product) ->getQty();

How to display static block content on front side?

$this->getLayout()->createBlock('cms/block')->setBlockId('identifier')->toHtml()

How to check customer is login or not?

Mage::getSingleton('customer/session')->isLoggedIn());

How to Get current Url of the page in magento?

$this->helper('core/url')->getCurrentUrl();

How to display product with specific height and width in magento?


$productId = 1;
$product = Mage::getModel('catalog/product') ->load($productId);
$path = Mage::helper('catalog/image') ->init($product, 'image') ->resize(75, 75);