Sunday, July 8, 2012

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);

How to set number of columns on product listing page?


<?php $_columnCount = $this->getColumnCount(); ?>
              and replace it with:
<?php $_columnCount = 4; ?>

How to create module in magento?


app/etc/modules/Custom_Manufacturerlogo.xml
app/code/local/Custom/Manufacturerlogo/Block/Manufacturerlogo.php
app/code/local/Custom/Manufacturerlogo/controllers/IndexController.php
app/code/local/Custom/Manufacturerlogo/etc/config.xml
app/code/local/Custom/Manufacturerlogo/Model/Manufacturerlogo.php
app/code/local/Custom/Manufacturerlogo/Model/Mysql4/Manufacturerlogo.php
app/code/local/Custom/Manufacturerlogo/Model/Mysql4/Manufacturerlogo/Collection.php
app/code/local/Custom/Manufacturerlogo/Model/Status.php
app/code/local/Custom/Manufacturerlogo/sql/manufacturerlogo_setup/mysql4-install-0.1.0.php
app/design/frontend/default/default/layout/manufacturerlogo.xml
app/design/frontend/default/default/template/manufacturerlogo/manufacturerlogo.phtml
app/code/local/Custom/Manufacturerlogo/Block/Adminhtml/Manufacturerlogo.php
app/code/local/Custom/Manufacturerlogo/Block/Adminhtml/Manufacturerlogo/Edit.php
app/code/local/Custom/Manufacturerlogo/Block/Adminhtml/Manufacturerlogo/Grid.php
app/code/local/Custom/Manufacturerlogo/Block/Adminhtml/Manufacturerlogo/Edit/Form.php
app/code/local/Custom/Manufacturerlogo/Block/Adminhtml/Manufacturerlogo/Edit/Tabs.php
app/code/local/Custom/Manufacturerlogo/Block/Adminhtml/Manufacturerlogo/Edit/Tab/Form.php
app/code/local/Custom/Manufacturerlogo/controllers/Adminhtml/ManufacturerlogoController.php
app/code/local/Custom/Manufacturerlogo/Helper/Data.php
app/design/adminhtml/default/default/layout/manufacturerlogo.xml

Sample valid credit card numbers for testing


Here is a list of sample/dummy/test credit card numbers, which are safe to use when you test credit card functionality on a website or application that involves credit card transactions. These credit card numbers validate properly but they are not actually in use.
American Express:
378282246310005
3111111111111117
343434343434343
370000000000002
340000000000009
371449635398431
378734493671000
Visa:
4111111111111111
4007000000027
4222222222222
4012888888881881
MasterCard:
5105105105105100
5111111111111118
5454545454545454
5500000000000004
5555555555551111
5555555555554444
Discover:
6011111111111117
6011000000000004
6011000990139424
6011601160116611
6111111111111116
Hope this helps. Thanks.