Magento 如果我知道产品的id,我如何在小部件网格中打印产品的链接
我在widget网格中有这个代码,在这个专栏中我有产品的Magento 如果我知道产品的id,我如何在小部件网格中打印产品的链接,magento,Magento,我在widget网格中有这个代码,在这个专栏中我有产品的id。我想打印链接到网格中的产品。我怎么能做到 我知道如何获得产品:$\u newProduct=Mage::getModel('catalog/product')->load($quote\u id) 谢谢 在网格中的列下方添加 … $this->addColumn('product_id', array( 'header' => $this->__('Product'),
id
。我想打印链接到网格中的产品。我怎么能做到
我知道如何获得产品:$\u newProduct=Mage::getModel('catalog/product')->load($quote\u id)代码>
谢谢 在网格中的列下方添加
…
$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;
}
}
<?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;
}
}