Wednesday 28 May 2014

Remove or rename add new save continue delete button from magento admin


If you don’t want to show the ‘Add New’ button in the Grid. The Add New button is present in top right corner of Grid Page.

Rename ‘Add New’ button

Here are the steps to rename the ‘Add New’ text to anything you required (for example, ‘Add Report’):-

- Go to YourNamespace -> YourModule -> Block -> Adminhtml -> YourFile.php
- Add the following code in the constructor of this file:-

$this->_addButtonLabel = Mage::helper('yourmodulename')->__('Add Report');

Remove ‘Add New’ button

Here are the steps to remove the ‘Add New’ button:-

- Go to YourNamespace -> YourModule -> Block -> Adminhtml -> YourFile.php
- Add the following code in the constructor of this file (it should be just below the call to parent constructor):-



parent::__construct();
$this->_removeButton('add');


In edit.php
parent::__construct();
$this->_removeButton('delete');
$this->_removeButton('save');
$this->_removeButton('back');

in grid.php
parent::__construct();
$this->_removeButton('add'); 

Tuesday 20 May 2014

Server front issues

<FilesMatch "\.(ttf|otf|eot|woff)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
  </IfModule>
</FilesMatch>

LInk:-http://red-team-design.com/firefox-doesnt-allow-cross-domain-fonts-by-default/

Monday 19 May 2014

way to display a thumbnail image in the admin grid view?

Step 1
======================================
Create Directories (if NOT there)
app/code/local/<Mycomapname>/<Mymodule>/Block/Adminhtml/Grid/
app/code/local/<Mycomapname>/<Mymodule>/Block/Adminhtml/Grid/Renderer/

Step 2
======================================
Create a file named “Image.php” at the following location
app/code/local/<Mycomapname>/<Mymodule>/Block/Adminhtml/Grid/Renderer/


 Step 3
======================================
Paste the following code into “Image.php” created above


class <Mycomapname>_<Mymodule>_Block_Adminhtml_Grid_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    
public function render(Varien_Object $row)
    
{
        
if($row->getData($this->getColumn()->getIndex())==""){
            
return "";
        
}
        else{
            $html 
'<img ';
            
$html .= 'id="' $this->getColumn()->getId() . '" ';
            
$html .= 'width="45" ';
            
$html .= 'height="35" ';
            
$html .= 'src="' Mage::getBaseUrl("media") . $row->getData($this->getColumn()->getIndex()) . '"';
            
$html .= 'class="grid-image ' $this->getColumn()->getInlineCss() . '"/>';
          
            return 
$html;
        
}
    }
}



 
Hi All,
You do not need to overwrite any thing at all, just follow these simple steps instead
Step 1
======================================
Create Directories (if NOT there)
app/code/local/<Mycomapname>/<Mymodule>/Block/Adminhtml/Grid/
app/code/local/<Mycomapname>/<Mymodule>/Block/Adminhtml/Grid/Renderer/
Step 2
======================================
Create a file named “Image.php” at the following location
app/code/local/<Mycomapname>/<Mymodule>/Block/Adminhtml/Grid/Renderer/
Step 3
======================================
Paste the following code into “Image.php” created above

class <Mycomapname>_<Mymodule>_Block_Adminhtml_Grid_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    
public function render(Varien_Object $row)
    
{
        
if($row->getData($this->getColumn()->getIndex())==""){
            
return "";
        
}
        else{
            $html 
'<img ';
            
$html .= 'id="' $this->getColumn()->getId() . '" ';
            
$html .= 'width="45" ';
            
$html .= 'height="35" ';
            
$html .= 'src="' Mage::getBaseUrl("media") . $row->getData($this->getColumn()->getIndex()) . '"';
            
$html .= 'class="grid-image ' $this->getColumn()->getInlineCss() . '"/>';
          
            return 
$html;
        
}
    }
}

Step 4
======================================
Open app/code/local/<Mycomapname>/<Mymodule>/Block/Adminhtml/<Mymodule>/Grid.php and paste the following code into the function protected function _prepareColumns() some where

$this->addColumn('<Tbl_Colname>', array(
            
'header'    => Mage::helper('<mycomapname>_<mymodule>')->__('Image'),
            
'align'     => 'left',
            
'width'     => '100px',
            
'index'     => '<Tbl_Colname>',
            
'type'      => 'image',
            
'escape'    => true,
            
'sortable'  => false,
            
'filter'    => false,
            
'renderer'  => new <Mycomapname>_<Mymodule>_Block_Adminhtml_Grid_Renderer_Image,
        ));



===================================================================