PHP Magento Tips

Add Product Edit Link In Category Product Tab in Magento Admin

Rate this posting:
{[['']]}

In Previous Post you can find we have added Product Edit Link In Category Product Tab in Magento Admin With Custom Renderer

Actually you can do this without custom renderer as per below:

Step 1: Create Module Initialization file. Create app/etc/modules/Mycompany_CategoryProductlink.xml file and add below code:

<?xml version="1.0"?>

<config>

    <modules>

        <Mycompany_CategoryProductlink>

            <active>true</active>

            <codePool>local</codePool>

        </Mycompany_CategoryProductlink>

    </modules>

</config>


Step 2: Create Main config.xml file. Create app/code/local/Mycompany/CategoryProductlink/etc/config.xml file and add below code in it:

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_CategoryProductlink>
            <version>0.1.0</version>
        </Mycompany_CategoryProductlink>
    </modules>
 <global>
        <blocks>
         <categoryproductlink>
          <class>Mycompany_CategoryProductlink_Block</class>
     </categoryproductlink>
    <adminhtml>
     <rewrite>
      <catalog_category_tab_product>Mycompany_CategoryProductlink_Block_Adminhtml_Catalog_Category_Tab_Product</catalog_category_tab_product>
     </rewrite>    
    </adminhtml>                   
        </blocks>      
  </global>
</config>

Here we rewrite <catalog_category_tab_product> node. So create your rewrite file for that.

Step 3: Create app/code/local/Mycompany/CategoryProductlink/Block/Adminhtml/Catalog/Category/Tab/Product.php file and add below code in it.

<?php
require_once 'Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php';
class Mycompany_CategoryProductlink_Block_Adminhtml_Catalog_Category_Tab_Product extends Mage_Adminhtml_Block_Catalog_Category_Tab_Product {

 /*Overwrite prepare column to provide edit functionality in category */
    protected function _prepareColumns()
    {
       parent::_prepareColumns();
       $this->addColumn('action',
            array(
                'header'    => Mage::helper('catalog')->__('Action'),
                'type'      => 'action',
                'getter'     => 'getId',
                'actions'   => array(
                    array(
                        'caption' => Mage::helper('catalog')->__('Edit'),
                        'url'     => array(
                            'base'=>'*/catalog_product/edit',
                            'params'=>array('store'=>$this->getRequest()->getParam('store'))
                        ),
                        //'target'=>'_blank',
                        'field'   => 'id',
                     'popup'   => true
                    )
                ),
                'filter'    => false,
                'sortable'  => false,
                'index'     => 'stores',
        ));
    }
}

Here we include core file and call other column with parent::_prepareColumns(); (see highlighted lines). And last we add our new column for product edit link.

By setting "popup'   => true" parameter edit product link will open in popup window instead of new blank window.


Download Whole Module from Github: https://github.com/vijayrami/Category_Productlink_Without_Renderer
0 Comments On "Add Product Edit Link In Category Product Tab in Magento Admin"

Back To Top