我正在尝试将“库存状态”列添加到Admin Manage Product Grid。库存状态为“库存”或“缺货”。
似乎我需要编辑Adminhtml/Block/Catalog/Product/Grid.php的_prepareColumns()。
我添加了这一行
$this->addColumn('stock',
array(
'header'=> Mage::helper('catalog')->__('Stock Avail.'),
'width' => '70px',
'index' => 'status',
'type' => 'options',
'options' => Mage::getSingleton('cataloginventory/source_stock')->toOptionArray()它只打印出Array,Array。
我猜它只是打印出类型,所以我需要访问数组值来获取选项。我走的路对吗?我找不到任何好的magento编码文档,如果有人能和我分享他们是如何理解magento的,那就太好了。
发布于 2011-08-17 17:44:28
您应该使用渲染器:在addColumn的数组中,添加:
'renderer' => 'YourNamespace_YourModule_Path_To_Renderer_File',渲染器文件如下所示:
class YourNamespace_YourModule_Path_To_Renderer_File extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
//let's see what you have to work with
Zend_Debug::dump($row->getData(), 'debug');
$stockStatus = $row->getSomething();
return $stockStatus;
}
}如果还不清楚,请告诉我
https://stackoverflow.com/questions/7086779
复制相似问题