Friday, August 31, 2012

Magento:: how to show admin path hints

>> Go to your phpMyAdmin and Run this query :

    INSERT INTO core_config_data SET scope = 'default', scope_id = 0,
            path = 'dev/debug/template_hints', value = 1;
    INSERT INTO core_config_data SET scope = 'default', scope_id = 0,
            path = 'dev/debug/template_hints_blocks', value = 1;

                                         To revert it change the value 1 to 0.

                ***********         Good Luck        **********

Monday, August 27, 2012

Magento::download zip from extension key

>> Place the extension key here and click submit button. After that you can see the download link on that page. see the link.


Friday, August 24, 2012

Create stylish select box in jquery

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>Stylish Select Box</title>
            <script src=""></script>
            <script type="text/javascript">
            // JavaScript Document
                // select element styling
                    var title = jQuery('option:first', this).text();
                    if( jQuery('option:selected', this).val() != ''  ) title = jQuery('option:selected',this).text();
                      if(jQuery(this).prev('span').text() == '' && jQuery(this).is(':visible')) {
                            .before('<span class="select">'+ title + '</span>')
                                val = jQuery('option:selected',this).text();
            <style type="text/css">
            .option_select_box select{
                color: #57462B;
                cursor: pointer;
                font-size: 12px;
                font-style: italic;
                height: 28px !important;
                line-height: 28px;
                margin: 0;
                position: relative;
                width: 115px !important;
            .selecttest {
                background: url(" ") no-repeat scroll 0 0 transparent;
                border: medium none;
                padding-right: 10px;
                position: relative;
                z-index: 1;
            .option_select_box span{
                background: url(" ") no-repeat scroll 0 0 transparent;
                color: #57462B;
                cursor: default;
                float: left;
                font-size: 12px;
                height: 28px;
                left: 0;
                line-height: 28px;
                overflow: hidden;
                position: absolute;
                text-align: left;
                text-indent: 10px;
                top: 0;
                width: 115px;
                z-index: 5;
            <div class="option_select_box">
              <select class="selecttest" name="">
                <option value="1">15 days</option>
                <option value="2">30 days</option>
                <option value="3">60 days</option>

see the Demo here. 

Wednesday, August 22, 2012

Product list with pagination in home page in Magento

>> In the backend Go to
   Go to Admin=>CMS->home page and  put the following code in the layout update xml

<reference name="content">
      <block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml"/>
      <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
              <action method="setCategoryId">
              <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
              <block type="page/html_pager" name="product_list_toolbar_pager"/>
              <action method="addColumnCountLayoutDepend">
              </action> <action method="setToolbarBlockName">
      <update handle="page_two_columns_right" />

Monday, August 20, 2012

Add first/last name in newsletter module Magento

 >> First add two fields ( subscriber_firstname, subscriber_lastname) in newsletter_subscriber table and app\design\frontend\THEME\default\template\newsletter\subscribe.phtml.

    >> Now edit this page : app\code\core\Mage\Newsletter\controllers\SubscriberController.php

        Here you'll find "public function newAction()"
            Paste the below code after this following code:
            $status = Mage::getModel('newsletter/subscriber')->subscribe($email);    //line (63)

     ///////////////////////// First Name //////////////////////////////

            if ($this->getRequest()->getPost('subscriber_firstname'))
                     $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
                     $name     = (string) $this->getRequest()->getPost('subscriber_firstname');

     //////////////////////  END  ///////////////////////////////////////

            Do same for field Last Name....

    >> The above code will effect your frontend. If you want to see the information from Admin too, you have to implement a little bit.

    Go to this link : app\code\core\Mage\Adminhtml\Block\Newsletter\Subscriber\grid.php
    Add this code :

    //It will show the information to the admin on News Letter Subscriber Section.
    $this->addColumn('subscriber_firstname', array(
            'header'    => Mage::helper('newsletter')->__('Subscriber First Name'),
            'index'     => 'subscriber_firstname',
            'default'   =>    '----'

    *Note :- I would suggest to override the subscriber controller and admin blocks. In this post I've focused in the logic only and shown in 3 steps to understand you its very simple. But it's not good programming. You should follow the magento module structure. In my another post you'll see that how to override frontend and admin controllers.

                                        ***********         Good Luck        **********


Magento:: how to get Review/Rating information

>> Get the review collection :

    $reviews = Mage::getModel('review/review')->getResourceCollection();
    $reviews->addStoreFilter( Mage::app()->getStore()->getId() )
          ->addStatusFilter( Mage_Review_Model_Review::STATUS_APPROVED )

>> Get the rating summary of a product:

    $summaryData  =  Mage::getModel('review/review_summary')
    foreach($summaryData as $s){
        $percentage = $s[rating_summary];
        $rev_count= $s[reviews_count];

>> Get the rating collection :

    $rating_collection = Mage::getModel('rating/rating')->getEntitySummary($_review->getEntityPkValue(),true);
    $rating_count = $rating_collection->getData('count');
    if (!empty($rating_count)) {
        $rating_sum = $rating_collection->getData('sum') / $rating_count;

Friday, August 17, 2012

Magento:: get Admin user details.

>>  Get admin information from admin page ::
    $userArray = Mage::getSingleton('admin/session')->getData();

    $user = Mage::getSingleton('admin/session');
    $userId = $user->getUser()->getUserId();
    $userEmail = $user->getUser()->getEmail();
    $userFirstname = $user->getUser()->getFirstname();
    $userLastname = $user->getUser()->getLastname();
    $userUsername = $user->getUser()->getUsername();
    $userPassword = $user->getUser()->getPassword();

>>  Get admin information from frontend::


            ***********         Good Luck        **********