0

我为横幅滑块创建了一个自定义模块。在管理网格中,我想显示网站字段。为此,我添加了 namespace/module/Block/Adminhtml/banner/Grid.php 文件

 if (!Mage::app()->isSingleStoreMode()) {
        $this->addColumn('website_id', array(
                'header'    => Mage::helper('bannerslider')->__('Website'),
                'align'     => 'center',
                'width'     => '80px',
                'type'      => 'options',
                'options'   => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
                'index'     => 'website_id',
        ));
      }

在 _prepareColumns() 函数中。现在我可以看到网站栏目了。但我无法在每一行中看到网站名称。如何在每行中显示网站名称。请看图片。

在此处输入图像描述

我缺少什么?


这是我的收藏。

protected function _prepareCollection()
  {
    $collection = Mage::getModel('bannerslider/bannerslider')->getCollection();
    $this->setCollection($collection);
    return parent::_prepareCollection();
  }

我的表中有一个名为“website_id”的字段。每行可能有多个以逗号分隔的值。在这种情况下你能告诉我如何使用集合吗?

4

2 回答 2

1

在 _prepareCollection() 函数中,插入:

parent::_prepareCollection();
$this->getCollection()->addWebsiteNamesToResult();
于 2013-06-13T09:22:48.103 回答
0

如果 website_id 在其他表中...,您需要加入表并在 _prepareCollection() 函数中的 select 中添加 website_id。

protected function _prepareCollection() {
   //Your custom code in here
}
于 2012-10-04T10:50:39.350 回答