Reputation: 1
I use magento 1.7 and i try to override the model Model Mage_Catalog_Model_Product_Attribute_Backend_Media but this doesn't work.
My class :
class Mycompany_Mymodule_Model_Catalog_Product_Attribute_Backend_Media extends Mage_Catalog_Model_Product_Attribute_Backend_Media
My config :
...
<model>
<catalog>
<rewrite> <product_attribute_backend_media>Mycompany_Mymodule_Model_Catalog_Product_Attribute_Backend_Media</product_attribute_backend_media>
</rewrite>
</catalog>
</model>
Can you help me ?
Thx
Upvotes: 0
Views: 459
Reputation: 28563
You do not need to over write any core files at all.
What you need to do is create 1 new files:
[Namespace]/[Module]/Block/[Adminhtml]/template/grid/renderer/Image.php
For the Image.php
class [Namespace]_[Module]_Block_[Adminhtml]_Template_Grid_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action {
public function render(Varien_Object $row)
{
return $this->_getValue($row);
}
public function _getValue(Varien_Object $row)
{
if ($getter = $this->getColumn()->getGetter()) {
$val = $row->$getter();
}
$val = $row->getData($this->getColumn()->getIndex());
$val = str_replace("no_selection", "", $val);
$url = Mage::getBaseUrl('media') . DS . $val;
$out = $val. '<center><a href="'.$_url.'" target="_blank" id="imageurl">';
$out .= "<img src=". $url ." width='60px' ";
$out .=" />";
$out .= '</a></center>';
return $out;
}
}
change code in the function as required to get to your folder, and error checking.
For the Grid.php add the following to one of your addColumns like below
$this->addColumn('image1', array(
'header' => Mage::helper('attributeimages')->__('Image 1'),
'align' => 'left',
'index' => 'image1',
'renderer' => '[module]/[adminhtml]_template_grid_renderer_image',));
Notice the ‘renderer’ option!
customize as you will
Upvotes: 1