Skip to main content

How to make Renderer in custom module magento

1)managedesign is my custom module
2) /app/code/local/Managedesign/Managedesign/Block/Adminhtml/Managedesign/Grid.php

    call rander method:
    "design_id" ia a database attribut;
    
        $this->addColumn("design_id", array(
            "header" => Mage::helper("managedesign")->__("Link"),
            "index" => "design_id",
            'renderer'  => 'managedesign/adminhtml_managedesign_renderer_image'

                ));
                
3)crerate a folder Renderer and make a file Image.php
    /app/code/local/Managedesign/Managedesign/Block/Adminhtml/Managedesign/Renderer/Image.php
    
    
    class Managedesign_Managedesign_Block_Adminhtml_Managedesign_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
     
    public function render(Varien_Object $row)
    {
        $html = '<img width="105" height="15" ';
        $html .= 'id="' . $this->getColumn()->getId() . '" ';
        $html .= 'src="' . Mage::getBaseUrl('web').'customizer/designs/'.$row->getData($this->getColumn()->getIndex()) . '_FRONT.png"';
        $html .= 'class="grid-image ' . $this->getColumn()->getInlineCss() . '"/>';
       $html .= '<br/><p><a href="'.$row->getData($this->getColumn()->getIndex()).'">Downlode Design</a></p>';
        return $html;
    }
}

Comments

Popular posts from this blog

How to add tab in Customer Information in Magento Admin

Step 1) Override the file /app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php, Inside _beforeToHtml() method, add the following code: $ this -> addTab ( 'Custom' , array (      'label'   = > Mage :: helper ( 'customer' ) -> __ ( 'Custom' ) ,      'class'   = >     'ajax' ,      'url'     = >     $ this -> getUrl ( '*/*/custom' , array ( '_current' = > true ) ) , ) ) ; Step 2)  Override the file /app/code/core/Mage/Adminhtml/controllers/CustomerController.php, Add the following code: public function customAction() { $this->_initCustomer(); $this->getResponse()->setBody( Mage::app()->getLayout()->createBlock('core/template')->setTemplate('custom/customer/tab/custom.phtml')->setCustomerId(Mage::registry('current_customer')->getId())         ->setUseAjax(true)-...

programaticaly Insert and select quary In magento

 INSERT QUERY include('../app/Mage.php'); Mage::app(); $write = Mage::getSingleton('core/resource')->getConnection('core_write'); $sql="INSERT INTO opd_uploads SET extension='$extension', sessionId='$sessionId', ip='$ip', status=1, dateTime=now()"; $write->query($sql); //lastInserted ID $imageId = $write->lastInsertId(); SELECT QUERY $read= Mage::getSingleton('core/resource')->getConnection('core_read');                   $value=$read->query("select * from opd_uploads WHERE id='".$imageRowId."'");          $row = $value->fetch();          $orgFilExt=$row['extension'];