Aug 25, 2011

Magento: GRID Important functions

Adding Edit link on a row

protected function _prepareColumns()
// .... Some other code here
'header' => Mage::helper('catalog')->__('Action'),
'width' => '50px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
'caption' => Mage::helper('catalog')->__('Edit'),
'url' => array(
'field' => 'id'
'filter' => false,
'sortable' => false,
'index' => 'stores',

Removing the Pager/Filter

Normally this is default on the magento grid already.

public function __construct()
$this->setFilterVisibility(false); // Remove Seach filtering
$this->setPagerVisibility(false); // Remove Pager of the grid

Adding Mass proccess on the Grid

protected function _prepareMassaction()
$this->getMassactionBlock()->addItem('delete', array(
'label'=> Mage::helper('download')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
'confirm' => Mage::helper('download')->__('Are you sure?')

$this->getMassactionBlock()->addItem('status', array(
'label'=> Mage::helper('download')->__('Change status'),
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
'additional' => array(
'visibility' => array(
'name' => 'status',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('download')->__('Status'),
'values' => array("x1" => "Yow", "x2"=>"secret")

Aug 23, 2011

Linux: Get SSL certificate

openssl s_client -connect


Magento: Exporting button on your data in a grid.

Adding Export button

In your Grid class(Package_Module_Block_Grid), find the method named _prepareColumns and add the code below.
$this->addExportType('*/*/exportCsv', Mage::helper('download')->__('CSV'));
$this->addExportType('*/*/exportXml', Mage::helper('download')->__('XML'));

Implement Export method/Action

In your action controller class (Package_Module_Adminhtml_DownloadController) create two methods.

class Globe_Download_Adminhtml_DownloadController extends Mage_Adminhtml_Controller_Action{

public function exportXmlAction() {
public function exportCvsAction() {
protected function _prepareDownloadResponse($fileName, $content, $contentType = 'application/octet-stream', $contentLength = null)
$session = Mage::getSingleton('admin/session');
if ($session->isFirstPageAfterLogin()) {
return $this;
->setHeader('Pragma', 'public', true)
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
->setHeader('Content-type', $contentType, true)
->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength)
->setHeader('Content-Disposition', 'attachment; filename=' . $fileName)
->setHeader('Last-Modified', date('r'))
->sendHeaders(); // Need to call this method after all you send the Headers.
if (!is_null($content)) {
return $this;


Thanks to the other author for sharing what they knows about magento development. In this post I only put the part of the code that I understand or I use it in my application.


Zend: Join Statement and example

Aug 21, 2011

Magento: Add custom renderer for a custom column grid

Good Example Here:

Aug 7, 2011

Linix: Create/Extract tar file

Create tar.gz file

tar -cvzf mytarfile.tar.gz <directory>

this means:
-c = create new archive
-v = be verbose
-z = compress using gzip
-f = filename to create for the new archive

Extract tar.gz file

tar -xzf mytarfile.tar.gz

Create tar.bz2 file

tar -cvjf mytarfile.tar.gz <directory>

this means:
-c = create new archive
-v = be verbose
-j = compress using bzip2
-f = filename to create for the new archive

Extract tar.bz2 file

tar -xpjf file.tar.bz2

Aug 3, 2011

Linux: perl-Net-SSLeay dependency error when installing Memcached with yum

Needs to update the packages.
Get data packages here depends on your system.

How to install reviewboard in centOS?

Requirements: Database:
MySQL v5.0.31 or newer
Web Server:
Apache + mod_python or fastcgi lighttpd + fastcgi
Start reviewboard Installation

TO BE CONTINUED: Thanks for visiting

Magento: Custom admin module.