Thursday, January 19, 2012

Magento Transactional Emails

Magento Provide Transitional emails which will allow to create or customize our won email template
Some of the Template variable which we can used in our customization or which are widely used and some magento provide by default

Sunday, January 15, 2012

Magento Layout Elements

Layout Elements Which magento generally used in there XML
label: It helps the label of the handle which is shown as a descriptive reference in some areas of the admin panel.
reference: It is used to link an already defined block in any layout XML. To add any child block to an existing block, to modify attributes of an existing block or to perform any action on an existing block, the reference element is used to link to the existing block. The reference element must have a name attribute which refers to the existing block name.
block: It is used to define a new block. This element is usually defined inside a reference element when we want to create a new block. The block element must have a name attribute, which is a unique identifier of the block in the layout and a type attribute, which defines the block class name. If the block is of type or subtype of core/template, it can also have the template attribute which defines the actual phtml template file to be used for rendering the block
remove: It is used to remove an existing block from the layout. The block to be removed is specified with the name attribute
action: It defines an action to be performed on the referenced or newly defined block. An action is simply a method of the block instance on which it is to be executed. The method attribute defines the method name in the block instance and all child elements of the action element are treated as parameters to the method. This element can be placed inside reference or block elements.
update: It will loads an existing layout handle into the current layout handle. It provides a kind of inheritance of layout handles. It must have the handle attribute, which defines the handle of the block to be included.

Magento Block Types

Magento uses some mostly commomn built-in blocks which are as follows.
core/template: It will renders a template defined by its template attribute. The majority of blocks defined in the layout are of type or subtype of core/template.
page/html: It's a subtype of core/template and defines the root block. All other blocks are child blocks of this block.
page/html_head: It will help the HTML head section of the page which contains elements for including JavaScript, CSS etc.
page/html_header: It will help the header part of the page which contains the site logo, top links, etc.
page/template_links: It is used to create a list of links. Links visible in the footer and header area use this block type.
core/text_list: This will allow Some blocks like content, left, right etc. are of type core/text_list. When these blocks are rendered, all their child blocks are rendered automatically without the need to call the getChildHtml() method.
page/html_wrapper: It is used to create a wrapper block which renders its child blocks inside an HTML tag set by the action setHtmlTagName. The default tag is <div> if no element is set.
page/html_breadcrumbs: It will help to define breadcrumbs on the page.
page/html_footer: It will help to define footer area of page which contains footer links, copyright message and other static links
core/messages: It will help to renders error/success/notice messages.
page/switch: It will help to used for the language or store switcher.

Note:There are many more but this are commonly used 

Magento How to Remove the Block through XML

Basically there are two ways to remove blocks in layout XML:
by using: <remove name="" />
by using: <action method="unsetChild">

Both are important to understand
<remove name="" /> will operate on a global context, after all the layouts are processed which means that it will remove the named layout block completely, regardless of which layout handle added it.

<action method="unsetChild"> operates on a localized context, specifically, in the context where you use it. So, if you want to remove a specific block from a specific layout handle and possibly insert it at another position or layout handle, you need to use this approach.

Let us understand with example
Use remove
<default>
    <!-- remove the language and store switcher and footer links blocks, we won't use them -->
    <remove name="top.menu" />
    <remove name="footer_links" />
</default>

Use unsetChild to move or rearrange blocks in your layout:
    <default>
        <!-- move the breadcrumb block from the top.bar child block back to the template root -->
        <reference name="top.bar">
            <action method="unsetChild"><name>breadcrumbs</name></action>
        </reference>

        <reference name="root">
            <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
        </reference>
    </default>

Friday, January 13, 2012

Magento Add product on home page

There are numerous ways to put products on your home page
New products on home page
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
New products on home page through xml

<reference name="content">
    <block type="catalog/product_new" template="catalog/product/new.phtml">
        <action method="setProductsCount"><count>5</count></action>
        <action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
        <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
        <action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
        <action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
        <action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
    </block>
</reference>

All products on home page
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}
All products from one categroy
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="4" template="catalog/product/list.phtml"}}

Tuesday, January 10, 2012

Magento add special character while importing Customer Data

Magento doesnot allow special Character for importing customer data generally
For Example In the Dutch translation the special characters do not (always) show up properly. If we have to import some data like sandéép through csv of magento import it will shows error
so best practice is
Go to .htaccess file and remove # from
AddDefaultCharset UTF-8
and
open the your csv file in .txt format and Save As under UTF-8 and then import the data in magento
Your special character will also get import in magento admin without any error

Magento display the custom attribute value in Frontend

Add an attribute from magento admin and that attribute should belong to corect attribute set
Then edit the template file either view.phtml or list.phtml
For example we are using in list.phtml
app/design/frontend/default/your-theme/template/catalog/product/list.phtml
and use one of these methods to pull your attribute on the product listing page (list or grid view):

<?php foreach ($_productCollection as $_product): ?>

    <!-- these are regular text attributes -->
      <?php echo $_product->getMyAttribute() ?>
      <?php echo $_product->getAnotherCustomAttribute() ?>
   
    <!-- this is dropdown attribute -->
      <?php echo $_product->getAttributeText('your_attribute') ?>
   
    <!-- this is a boolean attribute -->
      <?php echo $_product->getMyAttributeName() ? "Yes" : "No" ?>

<?php endforeach?>

Monday, January 9, 2012

Magento calling folder path

Magento uses its own structure to call the Particular file from specific folder
For example if we want to call the the .wsdl file which is stored in the app/modulename/etc/wsdl/your.wsdl

so we will write the code in our php file like this
 public function __construct()
    { 
        $this->_ yourWsdl = Mage::getModuleDir('etc', 'Mage_ Modulename')  . DS . 'wsdl' . DS . ' Modulename'
              . DS . ' your .wsdl';  
    }

Where  
your.wsdl is the file which is stored in the app/modulename/etc/wsdl/

Sunday, January 8, 2012

Magento Add Static Block through XML or Phtml

We are assuming  that you know how to add the static block through admin.We can add the Static block in any page through two ways

Add through xml

<block type="cms/block" name="cms_test_block">
                <action method="setBlockId"><block_id>test_block</block_id></action>
</block>

Through phtml files

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(' test_block')->toHTMl(); ?>

Magento Adding new field in category for admin

Adding an Attribute in Product quite simple we can add through admin but adding a field(attribute) in category cannot be achieved through admin so here is the simple solution for adding the attribute in Category through Database.Open the phpmyadmin.Here we need to work on three tables.
  1. eav_attribute
  2. eav_entity_attribute
  3. catalog_eav_attribute

Thursday, January 5, 2012

Magento How to get the Brand list in Product page

Add the Brand name on Product page

Note "manufacturer" is the Attribute code for Brand
<?php
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
?>
<ul id="manufacturer_list">
<?php foreach ($manufacturers as $manufacturer): ?>
<li><a href="#"><?php echo $manufacturer['label'] ?></a></li>
<?php endforeach; ?>
</ul>


Magento get the current URL and Name of category

Magneto registry make it easier to get the current category name and category url
The registry object we are interested in is ‘current_category’ and utilise the registry call getName() to create call to retrieve the needed information.

Category Name: Mage::registry('current_category')->getName();

Category URL: Mage::registry('current_category')->getUrl();

Wednesday, January 4, 2012

Adding review in Product page

1) Add form data to catalog.xml & view.phtml The first thing to do is to add the review blocks to
the correct XML reference in catalog.xml which is in

app > design > frontend > default > yourtheme > layout

you’ll see the <reference name=”content”> for the catalog_product_view class.
Inside this reference add the following code:
<block type="review/product_view_list" name="product.info.product_additional_data" as="product_review" template="review/product/view/list.phtml">
  <block type="review/form" name="product.review.form" as="review_form"/>
</block>

Now the XML is set up, you just need to echo it on the product page in
app > design > frontend > default > yourtheme > template > catalog > product > view.phtml

<?php echo $this->getChildHtml('product_review') ?>

Getting the reviews page URL for a product in the product page sidebar

Adding the Review url in your customization page
For example
Since it is a new block that is needed, you need new template file.

Add:
app/design/frontend/base/default/template/review/sidebar.phtml

Enter into it something like:
 <div class="block block-reviews">
    <div class="block-title">
        <strong><span>Reviews</span></strong>
    </div>
    <div class="block-content">
    <p><a href="<?php echo $this->getNewReview($this->getProductId()) ?>">NewReview</a></p>
    </div>
</div>

Monday, January 2, 2012

Remove Price from Custom Options

IF wana remove the price change indicators on the options of configurable products. The product shows the configurable options as a dropdown box at the moment.:

“Large +£20.00” and If want to just show the option name “Large”

You can easily remove by overriding the JS
Open the template file
catalog/product/view/type/options/configurable.phtml

Find the
   var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);

Replace with
 Product.Config.prototype.formatPrice = function(){
        return '';
    }
        var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);

Add New Indian Currency symbol


To Add New Rupee symbol in magento currency follow below steps:

1)Copy the below url in your browser and add the css in your css folder
http://cdn.webrupee.com/font
same with js
http://cdn.webrupee.com/js

2) Add the css and js in Page.xml

3) Add below code in root.xml
path of file: lib/Zend/Locale/Data/root.xml open file in wordpad
find:
currency type=”INR”
replace symbol Rs with: amp#x20B9; (use & for amp).

4. After this refersh cache from admin and manually delete cache from front var/cache folder.
Now in front end it will display new India rupee symbol.

Sunday, January 1, 2012

Magento Certified Developer Exam

Register for a Magento Certified Developer Exam today and Find the Test center 
Magento Launches Certified Developer Study Guides and  Certified Developer Study Guides Plus for preparing for the Certification exam.The study guide will help to go through the topic related to certification exam. Down load the PDF and explore through Topic.PDF can be downloaded under Resource Tab at the bottom

LinkWithin

Blog has moved, searching new blog...