【问题标题】:Adding Stock Status column to Manage Product Admin Page将库存状态列添加到管理产品管理页面
【发布时间】:2011-08-17 00:40:22
【问题描述】:

我正在尝试将“库存状态”列添加到管理员管理产品网格。 库存状态为“有货”或“缺货”。

似乎我需要编辑 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 的,那就太好了。

【问题讨论】:

    标签: magento admin


    【解决方案1】:

    你应该使用渲染器:在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;
        }
    }
    

    如果不清楚,请告诉我

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-05
      • 2020-06-18
      • 1970-01-01
      • 1970-01-01
      • 2020-08-24
      • 1970-01-01
      相关资源
      最近更新 更多