gpt4 book ai didi

magento adminhtml 自定义模块它显示了两次网格

转载 作者:行者123 更新时间:2023-12-04 13:43:25 26 4
gpt4 key购买 nike

我是 magento 的新手,遵循本指南 Custom Module with Custom Database Table

我已经将我已经存在的模块实现到后端 adminhtml。我正在从数据库中获取东西并在 adminhtml 页面上显示 ot。一切正常,除了我在 adminhtml 上获得了两次网格。我两次得到相同的网格。我已经看了 2 个小时的代码无法弄清楚。如果有人知道如何解决这个问题,我将非常感谢。干杯

这就是我 grid.php 中的代码

<?php

class Ecom_Pricenotify_Block_Adminhtml_Pricenotify_Grid extends Mage_Adminhtml_Block_Widget_Grid{
public function __construct()
{
parent::__construct();
$this->setId('pricenotifyGrid');
// This is the primary key of the database
$this->setDefaultSort('pricenotify_id');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
}

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

protected function _prepareColumns()
{
$this->addColumn('pricenotify_id', array(
'header' => Mage::helper('pricenotify')->__('Notification ID'),
'align' =>'left',
'width' => '50px',
'index' => 'pricenotify_id',
));

$this->addColumn('prod_id', array(
'header' => Mage::helper('pricenotify')->__('Product ID'),
'align' =>'left',
'width' => '50px',
'index' => 'prod_id',
));


$this->addColumn('prod_price', array(
'header' => Mage::helper('pricenotify')->__('Product Price'),
'align' =>'left',
'width' => '50px',
'index' => 'prod_price',
));

$this->addColumn('user_price', array(
'header' => Mage::helper('pricenotify')->__('User Price'),
'align' =>'left',
'width' => '50px',
'index' => 'user_price',
));

$this->addColumn('email', array(
'header' => Mage::helper('pricenotify')->__('E-Mail Address'),
'align' =>'left',
'width' => '150px',
'index' => 'email',
));

$this->addColumn('created_time', array(
'header' => Mage::helper('pricenotify')->__('Creation Time'),
'align' => 'left',
'width' => '120px',
'type' => 'date',
'default' => '--',
'index' => 'created_time',
));


$this->addColumn('status', array(

'header' => Mage::helper('pricenotify')->__('Status'),
'align' => 'left',
'width' => '80px',
'index' => 'status',
'type' => 'options',
'options' => array(
'success' => 'Inactive',
'pending' => 'Active',
),
));

return parent::_prepareColumns();
}

public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
}}

这个 indexAction 函数来自 Controller
  public function indexAction() {
$this->_initAction();
$this->_addContent($this->getLayout()->createBlock('pricenotify/adminhtml_pricenotify'));
$this->renderLayout();
}

最佳答案

我修好了它。我只需要注释掉

//$this->_addContent($this->getLayout()->createBlock('pricenotify/adminhtml_pricenotify'));

从 indexAction 我猜我正在加载它两次。

关于magento adminhtml 自定义模块它显示了两次网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6927166/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com