1
votes

How to add column to display sku in wishlist tab of customer view in magento admin panel?

In app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php, i have added below code under protected function _prepareColumns() to add SKU column in wishlist tab:

$this->addColumn('sku', array(
        'header' => Mage::helper('customer')->__('SKU'),
        'index' => 'sku',
        'width' => '100px'
    ));

After adding this code, SKU column is added but values (i.e. SKU of product) are not shown under this column.

Please help. How to display these values under SKU column.

1
You need to get the value of sku for each product. For example: $sku = Mage::getModel('catalog/product')->load($_product->getId())->getSku();Andrei
Thank you for your answer. can you plz tell me, where to add the code to get value of sku for each product in wishlist.phpAPS_CARE

1 Answers

0
votes

Extend to local code pool the following:

/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php

Create new grid item renderer at:

/app/code/local/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Sku.php

And copy the copy the contents of the existing item renderer into that file:

/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Grid/Renderer/Item.php

Create new renderer adminhtml template:

app/design/adminhtml/default/default/template/customer/edit/tab/view/grid/sku.phtml

As in the existing item adminhtml renderer template, load the $product and fetch the SKU from it:

$product = $this->getProduct();

echo $this->escapeHtml($product->getSku())

Change the function _construct at the top of the file to call new renderer template for fetching SKU value:

    parent::_construct();
    $this->setTemplate('customer/edit/tab/view/grid/sku.phtml');
    return $this;

Add SKU column to the function _prepareColumns:

    $this->addColumn('sku', array(
        'header'    => Mage::helper('catalog')->__('Product SKU'),
        'index'     => 'sku',
        'renderer'  => 'adminhtml/customer_edit_tab_view_grid_renderer_sku'
    ));

Resulting in:

Adding SKU column to backend customer wishlist grid