Tuesday, February 21, 2012

Magneto Removal of "/" for Duplicate Link

For SEO reasons store owners will often want to standardise the URL generation in their Magento store.so sometime duplicate link generate for the same page
Ex: :yourdomain.com/contactus/
       yourdomain.com/contacts

Both will open the same page but why two link it is not standard for SEO purpose
So,for removing "/" from url we need to update changes in the following files

Sunday, February 19, 2012

Magento Add NOINDEX,FOLLOW

Some time we required to show the NoIndex,Follow in some pages only like CMS page or category page
we can add the following code as per the page in there respective XML
Like we don't want to show the Contacts us page in NOINDEX,FOLLOW
So open the contacts xml and add the code

<reference name="head">
   <action method="setRobots"><value>NOINDEX,FOLLOW</value></action>
</reference>

Just refresh that page and you will get the Page in NOINDEX
Hope this will help you.....

Magento Get overall Bestselling Product

Magento Over all best selling Product on Home page
Add new function in files as per the version
- app/code/core/Mage/Sales/Model/Mysql4/Report/Bestsellers.php
- app/code/core/Mage/Sales/Model/Mysql4/Report/Bestsellers/Collection.php

Friday, February 10, 2012

Magento Edit the "Shipping & Handling" in Cart

Easy way to Edit the Text "Shiping & Handling" in Cart
Open the file  app/code/core/Mage/Sales/Model/Quote/Address/Total/shipping.php
Copy in local folder app/code/local/Mage/Sales/Model/Quote/Address/Total/shipping.php
And search for the  function fetch ()
in that you can edit the text for the "Shipping & handling" to Shipping or Some thing

Hope this will Help You

Thursday, February 9, 2012

Magneto add Manufacture in grid Column for Admin

Add the brand/manufacture in grid for admin
Just open the file \app\code\core\Mage\Adminhtml\Block\Catalog\Product\grid.php and
Paste in local folder app\code\local\Mage\Adminhtml\Block\Catalog\Product
and add the below code in  _prepareColumns( ) function

Thursday, February 2, 2012

How to show the Exact searh result in Magento

If you want to show the exact search reult for your products
Two things need to be changed

1) In admin system->configuration->catalog->catlogsearch->Search Type
 Make it as Like

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

LinkWithin

Blog has moved, searching new blog...