曾几何时我尝试创建一些自定义列.我创建了像我应该拥有的整个XML结构.我创建了控制器.我甚至创建了自定义网格控制器.
创建自定义网格后,我认为列将排序.我错了,错了.单击列标题不执行任何操作.
建议?
class Company_Googlemerchant_Block_Adminhtml_Products_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('gm_product_grid');
$this->setDefaultSort('id');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(false);
}
protected function _prepareCollection()
{
$storeId = 1;
$collection = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId);
$collection
->addAttributeToSelect('enable_googlemerchant')
->addAttributeToSelect('name')
->addAttributeToSelect('entity_id')
->addAttributeToSelect('type_id')
->addAttributeToSelect('status')
->addFieldToFilter('enable_googlemerchant', array( "eq" => '1') )
->addFieldToFilter('status', array( "eq" => '1') )
->addAttributeToSort('name', 'asc')
;
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('id', array(
'header' => Mage::helper('googlemerchant')->__('ID'),
'align' =>'left',
'index' => 'entity_id',
'width' => '100px',
));
$this->addColumn('product_name', array(
'header' => Mage::helper('googlemerchant')->__('Product Name'),
'align' =>'left',
'index' …Run Code Online (Sandbox Code Playgroud) 此功能设置Magento网格以显示具有相应"删除"操作的文件名列表.
问题是删除操作永远不会传递参数'filename'.(参见http://www.premasolutions.com/content/magento-manage-category-product-grid-edit-link)我有TESTDUMP用于验证,但它永远不会打印在下一页上.
'params'是'addColumn-> actions-> url'的合法行为吗?
更新:为控制器添加了构造和准备集合.也许是因为我正在使用的收藏类型?
Rogue_Googlemerchant_Block_Adminhtml_Exporter_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('googlemerchantGrid');
// This is the primary key of the database
$this->setDefaultSort('filename');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
}
protected function _prepareCollection()
{
$basePath = Mage::getBaseDir('base');
$feedPath = $basePath . '/opt/googlemerchant/';
$errPath = $basePath . '/var/log/googlemerchant/';
$flocal = new Varien_Io_File();
$flocal->open(array('path' => $feedPath));
$dataCollection = new Varien_Data_Collection();
foreach ($flocal->ls() as $item) {
$dataObject = new Varien_Object();
$dataObject->addData(
array(
'filename' => $item['text'],
'size' => $item['size'] / 1000 …Run Code Online (Sandbox Code Playgroud)