2014-03-07 96 views
0

我有這個代碼部件網格,在這一欄我有id的產品。我想打印鏈接到網格中的產品。我該怎麼做?如何我可以打印鏈接產品的部件網格,如果我知道他的ID

我知道我可以得到產品:$_newProduct = Mage::getModel('catalog/product')->load($quote_id);

$this->addColumn('product_id', array(
     'header'  => Mage::helper('magecom_quotes')->__('product_id'), 
     'align'   => 'left', 
     'filter_index' => 'product_id', 
     'index'   => 'product_id', 
     'type'   => 'text', 
     'truncate'  => 255, 
     'escape'  => true, 
    )); 

謝謝!

回答

2

在網格中添加下面列

… 
    $this->addColumn('product_id', array(
    'header' => $this->__('Product'), 
       'align' => 'center', 
       'index' => 'product_id', 
       'width' => '50px', 
       'renderer' => 'Namespace_Module_Block_Product' 
    )); 
    … 

現在我們將創建在參數渲染

<?php 

class Namespace_Module_Block_Product extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract 
{ 

    public function render(Varien_Object $row) 
    { 
     $productId = $row->getData($this->getColumn()->getIndex()); 
     $product = Mage::getModel('catalog/product')->load($productId); 
     $link='<a href="' . $product->getProductUrl(); . '">'.$product->getName().'</a>'; 
     return $link; 
    } 
} 

檢查下面的鏈接,幫助您在電網

創建自定義欄表示的塊

http://magento.ikantam.com/qa/how-add-custom-renderer-magento-grid

http://inchoo.net/ecommerce/magento/how-to-add-custom-renderer-for-a-custom-column-in-magento-grid/

您需要呈現。 (自定義在上面的鏈接,而不是圖像&簡短描述設置您的產品鏈接)。

希望這有助於你

+0

感謝!!!!!!!!!! –

相關問題