Wednesday 20 June 2012

How to set default all product in magento

Open the file  app/code/core/Mage/Page/Block/Html/Pager.php
in an editor and find the following lines:

public function getLimit()
    {
        if ($this->_limit !== null) {
            return $this->_limit;
        }
        $limits = $this->getAvailableLimit();
        if ($limit = $this->getRequest()->getParam($this->getLimitVarName())) {
            if (isset($limits[$limit])) {
                return $limit;
            }
        }
        $limits = array_keys($limits);
 
Replace these lines with this:

public function getLimit()
    {
        
//always show all
        
return 'all';
        
$limits $this->getAvailableLimit();
        if (
$limit $this->getRequest()->getParam($this->getLimitVarName())) {
            
if (isset($limits[$limit])) {
                
return $limit;
            
}
        }
        $limits 
array_keys($limits);
        return 
$limits[0];
    
}



Open the file app\code\core\Mage\Catalog\Block\Product\List/Toolbar.php in an editor and find the following lines:

 public function getAvailableLimit()
    {
        $currentMode = $this->getCurrentMode();
        if (in_array($currentMode, array('list', 'grid'))) {
            return $this->_getAvailableLimit($currentMode);
        } else {
            return $this->_defaultAvailableLimit;
        }
    }
 

Replace these lines with this:
 
 public function getAvailableLimit()
    {
        
if ($this->getCurrentMode() == 'list'{
            
return array(
 'all'=>__('All'),5=>5,10=>10,15=>15,20=>20,25=>25);
        
}
        
elseif ($this->getCurrentMode() == 'grid'{
            
return array(
'all'=>__('All'),9=>9,15=>15,30=>30,);
        
}
        
return parent::getAvailableLimit();
    
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.