Tuesday, January 12, 2016

How to get a layout block html in a controller Magento


>> Sometimes we need to update any block through ajax or need to reload a particular block. You can get the html with the following code.

  $this->loadLayout();
  $compareBlock = $this->getLayout()->createBlock('catalog/product_compare_sidebar');
  $compareBlock->setTemplate('catalog/product/compare/sidebar.phtml');
  $html = $compareBlock->toHtml();



Thursday, October 15, 2015

Use google map with multiple marker


  => We already aware of google map very well. Here I'll show you how can we show a dynamic map with multiple/single marker in your html page.

  •  Single Marker Map :  Here we'll pass the locations with latitude and longitude. see the below code:
                        <script src='https://maps.googleapis.com/maps/api/js?v=3.exp'></script>
<div style='overflow:hidden;height:350px;width:100%;'>
 <div id='gmap_holder' style='height:350px;width:100%;'></div>
</div>
<a href='http://www.maps-generator.com/'>maps-generator</a>
<script type='text/javascript' src='https://embedmaps.com/google-maps-authorization/script.js?id=36146cb0ad5227f5dc8c1bfb291b91c0f83c0c6d'></script> 
<script type='text/javascript'>
function init_map() {
var myOptions = {
zoom: 12,
center: new google.maps.LatLng(22.5736132, 88.3483409),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('gmap_holder'), myOptions);
marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(22.5736132, 88.3483409)
});
infowindow = new google.maps.InfoWindow({
content: '<strong>Jayanta Roy</strong><br>Kolkata, IN<br>'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
infowindow.open(map, marker);  // remove it to show the marker on click only
}
google.maps.event.addDomListener(window, 'load', init_map);
</script> 

         Here change the latitude and longitude shown as bold.
         You can get the latitude and longitude of your location here:    http://maps.googleapis.com/maps/api/geocode/json?address=YOUR ADDRESS/ZIP&sensor=false

  • Multiple Marker Map :  Here we'll create an array of the locations with latitude and longitude. see the below code:
        <script src='https://maps.googleapis.com/maps/api/js?v=3.exp'></script>
        <div style='overflow:hidden;height:350px;width:100%;'>
          <div id='gmap_holder' style='height:350px;width:100%;'></div>
        </div>
        <a href='http://www.maps-generator.com/'>maps-generator</a>
        <script type='text/javascript' src='https://embedmaps.com/google-maps-authorization/script.js?id=36146cb0ad5227f5dc8c1bfb291b91c0f83c0c6d'></script> 
        <script type='text/javascript'>
var locations = [
['Jayanta 1', 22.5683534, 88.36157129999999],
['Jayanta 2', 22.5418011, 88.3600216],
['Jayanta 3', 22.5736132, 88.3483409]
];
        function init_map(locations) {
            var myOptions = {
                zoom: 12,
                center: new google.maps.LatLng(22.5736132, 88.3483409),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            map = new google.maps.Map(document.getElementById('gmap_holder'), myOptions);
            var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {  
marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(locations[i][1], locations[i][2])
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
 infowindow.setContent(locations[i][0]);
 infowindow.open(map, marker);
}
})(marker, i));
infowindow.open(map, marker);
}
        }
        google.maps.event.addDomListener(window, 'load', init_map(locations));
        </script> 


   

Saturday, October 10, 2015

How to know the order can ship OR not in Magento


=> In Magento if your order contains virtual and downloadable products then the shipping section in chekout step will hide. For your custom condition you can use the below code:


$quote = Mage::getSingleton('checkout/session')->getQuote();
if($quote->isVirtual()){
echo "No Ship";
}else{
echo "Ship";
}

Monday, March 30, 2015

Generate static block dropdown in System Configuration in Magento

>    First you need to create the system configuration menu. You'll find many tutorial to create system configuration menu. So, in your system.xml you need add a Source Model like "module/system_config_source_cms_block". Now create a directory in your module: YoureModule/Model/System/Config/Source/Cms/Block.php

Now your Block.php looks like below :

<?php
class CompanyName_YourModule_Model_System_Config_Source_Cms_Block
{

    protected $_options;

    public function toOptionArray()
    {
        if (!$this->_options) {

$collection = Mage::getModel('cms/block')->getCollection();
$staticBlock = array(''=>'-- Select Static Block --');
foreach($collection as $block){
$staticBlock[$block->getIdentifier()] = $block->getTitle();
}

            $this->_options = $staticBlock;
        }
        return $this->_options;
    }

}
?>

Refresh cache to see changes.


Wednesday, March 19, 2014

Magento :: $_product->getAttributes() not working in listing page

     
>>  With the following code every-time you'll get same attributes as it first load the attributes of product and store in a variable. Then from the second time it'll check the variable for the attributes.

        $attributes = $_product->getAttributes();
        foreach ($attributes as $attribute) {
            if ($attribute->getIsVisibleOnFront()) {
                $value = $attribute->getFrontend()->getValue($_product);
                $attributeLabel = $attribute->getFrontendLabel();
                $attributeCode = $attribute->getAttributeCode();
            }
        }
       
        In the above code you'll get the product attribute details and value in listing page if the attribute_set_id for all products in listing page is same. But if the attribute_set_id of all products are different, you need to change your code:
                $attributes = $_product->getAttributes();  
                //Replace this with the following
                $attributes = Mage::getModel('catalog/product')->getResource()
                                      ->loadAllAttributes()
                                      ->getSortedAttributes($_product->getAttributeSetId());



Friday, March 14, 2014

get catalog rule applied price of product in Magento


 >> We use to get product price like :
                       $_product->getPrice();
                       $_product->getFinalPrice();
     
      Here you can get the catalog rule applied price like:
            $store_id = Mage::app()->getStore()->getId();
            $discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
                                                      Mage::app()->getLocale()->storeTimeStamp($store_id),
                                                      Mage::app()->getStore($store_id)->getWebsiteId(),
                                                      Mage::getSingleton('customer/session')->getCustomerGroupId(),
                                                                      $_product->getId());
               
           
            if ($discountedPrice===false) { // if no rule applied for the product
                $discountedPrice = $_product->getFinalPrice();
            }else{
                $discountedPrice = number_format($discountedPrice,2);
            }




Thursday, February 6, 2014

Convert special character to normal character in PHP

   
    > You need to convert special character to normal character. Below are the list of some special character:
   
    $special_chars = array(
        'À','à','Á','á','Â','â','Ã','ã','Ä','ä','Å','å','Ă','ă','Ą','ą',
        'Ć','ć','Č','č','Ç','ç',
        'Ď','ď','Đ','đ',
        'È','è','É','é','Ê','ê','Ë','ë','Ě','ě','Ę','ę',
        'Ğ','ğ',
        'Ì','ì','Í','í','Î','î','Ï','ï',
        'Ĺ','ĺ','Ľ','ľ','Ł','ł',
        'Ñ','ñ','Ň','ň','Ń','ń',
        'Ò','ò','Ó','ó','Ô','ô','Õ','õ','Ö','ö','Ø','ø','ő',
        'Ř','ř','Ŕ','ŕ',
        'Š','š','Ş','ş','Ś','ś',
        'Ť','ť','Ť','ť','Ţ','ţ',
        'Ù','ù','Ú','ú','Û','û','Ü','ü','Ů','ů',
        'Ÿ','ÿ','ý','Ý',
        'Ž','ž','Ź','ź','Ż','ż');
       
         Now try the below code to convert these to normal character :
       
        $text = "éèçâñüÄ";
        $htmlchar = htmlentities($text, ENT_COMPAT, 'UTF-8');  //éèçâñüÄ
        $text = preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities($text, ENT_COMPAT, 'UTF-8'));  //eecanuA

           
       
       

Tuesday, January 21, 2014

Uses of $this->getChildHtml() in Magento


        >> $this->getChildHtml() is a known features to include a child block in a page. I'm simplifying this with an example:
     
      In your XML : 
       <block type="core/template" name="parent_block" template="example/test.phtml">
             <block type="core/template" name="child_block" template="example/test_child.phtml"/>
       </block>

      Now in your test.phtml you can include the child block like : 
             <?php echo $this->getChildHtml('child_block'); ?>

      
       >> You can also pass a variable to this block. I've shown this in my previous post. Now if you want to pass dynamic value to the child block, here's it:

           <?php
                $this->getChild('child_block')->setData('product_id', $productId);
                echo $this->getChildHtml('child_block', false);
            ?>


         Here $productId is your dynamic value and you need to pass "false" (Block Caching No) as  additional parameter in childHtml(). By default it takes "true" (Block Caching Yes).
     
        You can get the product id in test_child.phtml with $this->getProductId()




Tuesday, December 3, 2013

How to create custom category attribute in Magento


>> If you need to create a category attribute there's no option in magento admin. You need to create it through code or sql. I'm showing the two:

1) Here you can use this code with a new module or create a upgrade sql  for an existing module and write below code by changing your attribute code/Label name.

$installer = $this;
$installer->startSetup();

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$setup->addAttribute('catalog_category', 'custom_attribute', array(
    'type' => 'int',        // "varchar" for input type text box
    'group'     => 'General Information',
    'backend' => '',
    'frontend' => '',
    'label' => 'Custom Attribute',
    'input' => 'select',    // "text" for input type text box
    'class' => '',
    'source' => 'eav/entity_attribute_source_boolean',            // Leave blank for input type text box
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible' => true,
    'required' => false,
    'user_defined' => false,
    'default' => '0',        //Leave blank for input type text box
    'searchable' => false,
    'filterable' => false,
    'comparable' => false,
    'visible_on_front' => false,
    'unique' => false,
));

$installer->endSetup();

                                                                           OR
2)  Or you can run direct sql like this way:

        INSERT INTO `eav_attribute` (`attribute_id`, `entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`, `is_user_defined`, `default_value`, `is_unique`, `note`) VALUES ('', 3, 'mp3', NULL, '', 'varchar', '', '', 'text', 'Mp3 URL', '', '', 1, 0, '', 0, '');

**** Suppose last inserted ID is 134. This ID will place in the following two table.

        INSERT INTO `eav_entity_attribute` (`entity_attribute_id`, `entity_type_id`, `attribute_set_id`, `attribute_group_id`, `attribute_id`, `sort_order`) VALUES ('', 3, 3, 3, 134, 10);

   Note:- Please check in your database for your attribute type_id , set_id and group_id.

        INSERT INTO `catalog_eav_attribute` (`attribute_id`, `frontend_input_renderer`, `is_global`, `is_visible`, `is_searchable`, `is_filterable`, `is_comparable`, `is_visible_on_front`, `is_html_allowed_on_front`, `is_used_for_price_rules`, `is_filterable_in_search`, `used_in_product_listing`, `used_for_sort_by`, `is_configurable`, `apply_to`, `is_visible_in_advanced_search`, `position`, `is_wysiwyg_enabled`, `is_used_for_promo_rules`) VALUES (134, '', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, '', 0, 0, 0, 0);


Note* : Will suggest to follow the first step and follow the second to know the table reference.



Friday, November 29, 2013

How to remove State/Region from Estimate Shipping in Magento


If you want to remove the State/Region dropdown from Estimate shipping block. Find the code
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);  and comment out in the app/design/frontend/enterprise/default/template/checkout/cart/shipping.phtml directory



Tuesday, August 13, 2013

Programmatically change product attribute value in a store Magento


>> We have already known that magento has the save() method to save the data through model. We can save a product data programmatically with the product object. Here's a example:

            $_product = Mage::getModel('catalog/product')->load("PRODUCT_ID");
            $_product->setData('name','value');   OR   $_product->setName('value');
            $_product->save();
            // With this we can change the product name. But the save() method will save globally.

Now suppose you need to change a product visibility for a particular store. Then using this code you can change a particular attribute for a store without saving entire product attributes. Here's it :

            $_product = Mage::getModel('catalog/product')->load("PRODUCT_ID");
            $_product->setStoreId(1);
            $_product->setVisibility(1);
            $_product->getResource()->saveAttribute($_product, 'visibility');




Thursday, August 1, 2013

How to use WYSIWYG editor in Admin form field Magento


>> You need to do two small changes. Here's it

    1) open the Edit.php page on your module Yourmodule_Block_Adminhtml_Yourblock_Edit
    Add the method.

     protected function _prepareLayout() {
        parent::_prepareLayout();
        if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
            $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
        }
    }


    2) Now open the Form.php change the field you want to change like following:

        $fieldset->addField('description', 'editor', array(
            'name'      => 'description',
            'label'     => Mage::helper('Youmodule')->__('Content'),
            'title'     => Mage::helper('Youmodule')->__('Content'),
            'style'     => 'height:300px; width:700px',
            'config'    => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
            'wysiwyg'   => true,

            'required'  => false,
        ));

     ...........................

Friday, July 26, 2013

Magento :: get static block content mapped with category


>> You can display a static block in a category page by Managing the category from admin.



     But if you want the block in a custom page for that category. You use the following code:

         // load the category
        $_category = Mage::getModel('catalog/category')->load($categoryId);
       
        // Fetching the block data
        $html = $this->getLayout()->createBlock('cms/block')
                    ->setBlockId($_category->getLandingPage())
                    ->toHtml();
                   
        echo $html;





Thursday, July 4, 2013

All categories of a product show in breadcrumbs in magento


>> Here's I've shown how to show all categories of a product in breadcrumbs. It looks like :
      Home / cat1 | Home / cat1 / cat2 | Home / cat3 / Product  You can use a separator before every Home link.
  Edit the file app/code/core/Mage/Catalog/Block/Breadcrumbs.php
 Note* : You must copy the file in your local directory OR override the block before Edit.

Find the method _prepareLayout() and replace with the following code:

        protected function _prepareLayout()
        {
            if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
              
                /************                Customize for product breadcrumbs            ***********/
                                              
                $product = $this->getProduct();
                $categories = $product->getCategoryIds();
                $parentArr = array();
                $childArr = array();
              
                foreach($categories as $catId){
                    if($catId != 2){
                        $category = Mage::getModel('catalog/category')->load($catId);
                      
                        if(in_array($category->getParentId(),$categories) && $category->getParentId() != 2){
                            if(!array_key_exists($category->getParentId(),$parentArr)){
                                $childArr[] = $category->getId();
                                $parentArr[$category->getParentId()] = $childArr;
                            }else{
                                if($parentArr[$category->getParentId()] == '') $childArr = array();
                                array_push($childArr,$category->getId());
                                $parentArr[$category->getParentId()] = $childArr;
                            }
                        }else{
                            $parentArr[$category->getId()] = '';
                        }
                    }
                }
              
                $i=0;
                foreach($parentArr as $pId => $cArr){
                    $cat = Mage::getModel('catalog/category')->load($pId);
                    $firstClass = ($i++ == 0) ? $cat->getId().' first' : $cat->getId();
                  
                    $breadcrumbsBlock->addCrumb('home product '.$firstClass, array('label'=>Mage::helper('core')->__('Home'),
                                                'title'=>Mage::helper('core')->__('Home Page'), 'link'=>Mage::getBaseUrl()));
                    $breadcrumbsBlock->addCrumb(strtolower(str_replace(' ','_',$cat->getName())), array('label'=> $cat->getName(),
                                                    'title'=> $cat->getName(), 'link'=> $cat->getUrl()));
                    foreach($cArr as $cId){
                        $child = Mage::getModel('catalog/category')->load($cId);
                        $breadcrumbsBlock->addCrumb('home product '.$cId.$cat->getId(), array('label'=>Mage::helper('core')->__('Home'),
                                                    'title'=>Mage::helper('core')->__('Home Page'), 'link'=>Mage::getBaseUrl()));
                        $breadcrumbsBlock->addCrumb(strtolower(str_replace(' ','_',$cat->getName())).$cId, array('label'=> $cat->getName(),
                                                        'title'=> $cat->getName(), 'link'=> $cat->getUrl()));
                        $breadcrumbsBlock->addCrumb(strtolower(str_replace(' ','_',$child->getName())), array('label'=> $child->getName(),
                                                    'title'=> $child->getName(), 'link'=> $child->getUrl()));
                    }      
                }
                if(count($parentArr) == 0){
                    $breadcrumbsBlock->addCrumb('home product first', array('label'=>Mage::helper('core')->__('Home'),
                                                'title'=>Mage::helper('core')->__('Home Page'), 'link'=>Mage::getBaseUrl()));
                }
                $breadcrumbsBlock->addCrumb('prod'.$product->getId(), array('label'=> $product->getName(), 'title'=> $product->getName(), 'link'=> ''));
              
                /***********            Customize for product breadcrumbsBlock    END            *************/
              
            }
            return parent::_prepareLayout();
        }

Thursday, June 27, 2013

how to redirect referer page after login in magento


>> Only admin setting (step 1) needed to redirect customer after login. Using this I'm showing how will you restrict a page only for registered customer. If someone click the url www.example.com/restricted_page.html, it'll redirect to login page. Then after login it should redirect back to the www.example.com/restricted_page.html.
Here's how I did it :

    Step 1: Go to Admin => System => Configuration => Customer Configuration => Login Options => "Redirect Customer to Account Dashboard after Logging in" set it "No".
 
    Step 2: If you're using a module page then you've the controller Action method like:
  
            public function indexAction()
            {
                // use here to restrict the page //
                if(!Mage::helper('customer')->isLoggedIn()){
                    Mage::getSingleton('customer/session')->setBeforeAuthUrl('Restricted Page Url');
                       $this->_redirect('customer/account/login');
                }
                //        End your addition //

              
                $this->loadLayout();   
                $this->renderLayout();
            }
            you can use one of this code to redirect:
 
            Mage::getSingleton('customer/session')->setBeforeAuthUrl('Restricted Page Url');
            $this->_redirect('customer/account/login');
         
                                OR
                             
            $this->_redirect('customer/account/login/referer/'.Mage::helper('core')->urlEncode('Restricted Page Url'));
          
    Step 3: (optional) If you're using a cms page then follow this step:
          
            In your admin CMS section include a phtml page and write the below code at the top of the page:
          
            if(!Mage::helper('customer')->isLoggedIn()){
                Mage::getSingleton('customer/session')->setBeforeAuthUrl('Restricted Page Url');
                $this->_redirect('customer/account/login');
            }
          
>> Now if you want to use the login url inside a page with referer url follow this:
      
    <?php $referer = Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl()); ?>
    <a href="<?php echo Mage::getUrl('customer/account/login', array('referer' => $referer)) ?>">Login</a>
  
  
  
      

Monday, June 24, 2013

How to add multi-select attribute in Admin product Grid view


Here I've shown a multi-select attribute named "brand".

>> In admin Grid.php find the method "_prepareColumns()" add the following code:

        $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'brand');        // attribute code here
        foreach ( $attribute->getSource()->getAllOptions(true, true) as $option)
        {
            if($option['value'] != '')
            $valArr[$option['value']] =  $option['label'];
        }
        // above code will use to show the dropdown
       
        $this->addColumn('brand',
            array(
                'header'=> Mage::helper('catalog')->__('Brands'),
                'width' => '60px',
                'index' => 'brand',
                'type'  => 'options',
                'options' => $valArr,
                'renderer'  => 'Mage_Adminhtml_Block_Catalog_Product_Renderer_Brands', // Will have to create the renderer.
                'filter_condition_callback' => array($this, '_filterBrandCondition')
        ));
       
        Then in this page you need to define the method "_filterBrandCondition" to filter with selected item.
       
        protected function _filterBrandCondition($collection, $column)
        {
            if (!$value = $column->getFilter()->getValue()) {
                return;
            }
            $this->getCollection()->addFieldToFilter('brand', array('finset' => $value));
        }
       
       
>> Now create the Brands.php file in code/local/Mage/Adminhtml/Block/Catalog/Product/Renderer directory and use the following code:

        class Mage_Adminhtml_Block_Catalog_Product_Renderer_Brands extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
        {
            public function render(Varien_Object $row)
            {
                $brands = explode(',',$row->getBrand());
                $html = "";
                if(count($brands)>0)
                {
                    $html ="<ul>";
                    foreach($brands as $value)
                    {
                        $_productModel = Mage::getModel('catalog/product');
                        $attribute = $_productModel->getResource()->getAttribute("brand");
                        if ($attribute ->usesSource()) {
                            $html .= "<li>".$attribute ->getSource()->getOptionText("$value")."</li>";
                        }
                    }
                    $html .= "</ul>";
                }
                return $html ;
            }
        }
       
 cheer :-)


Wednesday, May 29, 2013

Add extra cost to every shipping method in Magento


>>  I needed to add extra cost to every shipping method price. There would be any other better way to do it but I did the following :

         Open the Rate.php file within app/code/core/Mage/Sales/Model/Quote/Address directory. Find this method:
    public function importShippingRate(Mage_Shipping_Model_Rate_Result_Abstract $rate)
    {
        if ($rate instanceof Mage_Shipping_Model_Rate_Result_Error) {
            $this
                ->setCode($rate->getCarrier().'_error')
                ->setCarrier($rate->getCarrier())
                ->setCarrierTitle($rate->getCarrierTitle())
                ->setErrorMessage($rate->getErrorMessage())
            ;
        } elseif ($rate instanceof Mage_Shipping_Model_Rate_Result_Method) {
            $this
                ->setCode($rate->getCarrier().'_'.$rate->getMethod())
                ->setCarrier($rate->getCarrier())
                ->setCarrierTitle($rate->getCarrierTitle())
                ->setMethod($rate->getMethod())
                ->setMethodTitle($rate->getMethodTitle())
                ->setMethodDescription($rate->getMethodDescription())
                ->setPrice($rate->getPrice())
            ;
        }
        return $this;
    }

    Add extra 10 price with $rate->getPrice() like :  
                   ->setPrice($rate->getPrice()+10)


  Note: Editing the core file is not a good practice. If anyone find any other solution, please must share with me. :)

Monday, April 29, 2013

Import dump data to mysql through command promt


>> Mysql import from CSV :

      > mysqlimport --fields-terminated-by=, --fields-enclosed-by="\"" --lines-terminated-by="\r\n" DBNAME FILEPATH -u USERNAME -p --columns=code,city,state,county


Thursday, April 18, 2013

How to get all subcategories of a category in Magento


 >> Suppose you need to get the list of all subcategory of "cat1" (id : 10)

    <?php
       $category = Mage::getModel('catalog/category')->load(10); // load the parent category
    ?>
    There are many way to do it. I'll show you the two :
   
    1. $subcatCollection = Mage::getModel('catalog/category')->getCollection()
                ->addAttributeToSelect('*')
                ->addAttributeToFilter('is_active','1')
                ->addAttributeToFilter('parent_id',array('eq' => 10));
               
       // This will return the subcategory collection.
               
   2. $subcategories = $category->getChildren();
   
       // This will return all subcategory id with comma separator like : 11,12,13


Thursday, April 11, 2013

How to show review block on product page in Magento

>> To get the review block in product details page. You need to follow the two steps:

       1) Add this code to catalog.xml like:
            <catalog_product_view translate="label">
                <reference name="content">
                    <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
                       
                            <!--You need to copy below section -->
                        <block type="page/html_pager" name="product_review_list.toolbar"/>
                        <block type="core/template" name="product_review_list.count" template="review/product/view/count.phtml" />
                        <block type="review/product_view_list" name="product.detail.info.product_additional_data" as="product_review_data" template="review/product/view/list.phtml">
                            <block type="review/form" name="product.review.form" as="review_form">
                                <block type="page/html_wrapper" name="product.review.form.fields.before" as="form_fields_before" translate="label">
                                    <label>Review Form Fields Before</label>
                                    <action method="setMayBeInvisible"><value>1</value></action>
                                </block>
                            </block>
                        </block>
                            <!--        END            -->

                  
                   </block>
               </reference>
            </catalog_product_view>
           
       2) Now go to the view.phtml page. here you need to add this code:
      
               <?php echo $this->getChildHtml('product_review_data') ?>
           
            you are done> :)
           
           
>> To change the default number of reviews shown per page, follow this:

        By default it shows 10, 20, 50. Go to app/code/core/Mage/Page/Block/Html/Pager.php
        there you can find the line 
            <?php protected $_availableLimit = array(10=>10,20=>20,50=>50);  ?>
           
        change it as you want        
            <?php protected $_availableLimit = array(5=>5,10=>10,50=>50);  ?>
           
   Note*: You should do this step either by overriding the block OR copy the same file in the local directory like:  app/code/local/Mage/Page/Block/Html/Pager.php