Thursday, April 19, 2012

Magento User Sessions Mixed Up ,full page cache

One day I faced a new problem in magento enterprise edition. When a new user create account and goes to my account section the welcome message display right ...but when user goes to others CMS pages the welcome messages change with another name. I was very frestrated with this problem and after digging 1 hour finally I overcome this probelm.
The realy problem was that ful page caching was on in admin caching section.

admin->system->caching management


I disable that one and everything become correct.

Hope this will help someone.

Cheers!!!!!!!!

Friday, April 6, 2012

How to show cutomer street address in Admin Grid like street1 and Street2 :Solved

Hi
I search everywhere to show the street address in customer grid in admin end But no found any solution for this.
Finally I review the code and make a new way to do this .

1. copy file Grid.php form ...app\code\core\Mage\Adminhtml\Block\Customer\Grid.php  to .....app\code\local\Mage\Adminhtml\Block\Customer\Grid.php



2. open the customer 's Grid.php in ....app\code\local\Mage\Adminhtml\Block\Customer\Grid.php

and add the follwing code in _prepareColumns() function

\\\\\\\\\\\\\\\\\\\\\


 $this->addColumn('street1', array(
          'header'    => Mage::helper('customer')->__('Street 1'),
          'index'     => 'entity_id',
 'renderer'=> new Mage_Adminhtml_Block_Customer_Renderer_Street1()
         ));
$this->addColumn('street2', array(
          'header'    => Mage::helper('customer')->__('Street 2'),
          'index'     => 'entity_id',
 'renderer'=> new Mage_Adminhtml_Block_Customer_Renderer_Street2()
         ));


\\\\\\\\\\\\\\\\\\\\\\\

2. make a directory in  ....app\code\local\Mage\Adminhtml\Block\Customer\     named  Renderer

and create two files in  ....app\code\local\Mage\Adminhtml\Block\Customer\Renderer\

Street1.php
for code
\\\\\\\\\\\\\\\\

class Mage_Adminhtml_Block_Customer_Renderer_Street1 extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{

public function render(Varien_Object $row)
{
$value =  $row->getData($this->getColumn()->getIndex());

 $customer = Mage::getModel('customer/customer')
 ->load($value); //put customer id here

$data = array();

 foreach ($customer->getAddresses() as $address)
 {

    $data = $address->getStreet(1);

 

 }
 if(empty($data))
 {
 return '';
 }else{
 return $data;
 }



}

}


\\\\\\\\\\\\\\\\\

and second one is Street2.php

\\\\\\\\\\\\\\\\\\\\\\\\\\\\

class Mage_Adminhtml_Block_Customer_Renderer_Street2 extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{

public function render(Varien_Object $row)
{
$value =  $row->getData($this->getColumn()->getIndex());

 $customer = Mage::getModel('customer/customer')
 ->load($value); //put customer id here

$data = array();

 foreach ($customer->getAddresses() as $address)
 {

    $data = $address->getStreet(2);

    //var_dump($data);

 }
if(empty($data))
 {
 return '';
 }else{
 return $data;
 }

}

}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


and that all done.


Enjoy!!

Thursday, April 5, 2012

Store view is not listing in admin magento: SOLVED

In magento 1.6.X there may be a that multiple store listing not comes in admin end.
i comes to accross this issue and find out the solution
go to file ...app\code\core\Mage\Adminhtml\Block\Widget\Grid.php


and replace this code



public function getRowUrl($item)
    {
        $res = parent::getRowUrl($item);
        return ($res ? $res : '#');
    }

with



public function getRowUrl($item)
    {
        $res = parent::getUrl($item);
        return ($res ? $res : '#');
    }


and enjoy!!!!!!!

Monday, April 2, 2012

Change toolbar select to label magento


  <div style="float:left;width: 54%;">
    <div class="amount" style="float: left; ">
            <?php if($this->getLastPageNum()>1): ?>
                <?php echo $this->__('Viewing Items %s-%s of %s ', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
            <?php else: ?>
<?php echo $this->__('Viewing Items %s-%s of %s ', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
            <?php endif; ?>
        </div>

        <div class="limiter" style="float: right; padding-right: 34px;">
            <label><?php echo $this->__('View') ?></label> &nbsp;&nbsp;
           <?php $cnt=1;?>
            <?php foreach ($this->getAvailableLimit() as  $_key=>$_limit): ?>
                <a href="<?php echo $this->getLimitUrl($_key) ?>">
                    <?php echo $_limit ?>
                </a><?php echo ($cnt==4?'':'&nbsp;|&nbsp')?>
<?php $cnt++; ?>
  <?php endforeach; ?>
           &nbsp; <?php //echo $this->__('per page') ?>
        </div>

    </div>