When creating a custom adminhtml grid, I've run into a very strange issue when modifying the column type in the database from for instance Date to varchar:
Initially - works 100% (as type Date in the table):
$this->addColumn('credit_date',
array(
'header'=> $this->__('Credit<br/>Date'),
'index' => 'credit_date',
'width' => '5%',
'type' => 'date'
)
);
Updated to varchar in the table:
$this->addColumn('credit_date',
array(
'header'=> $this->__('Credit<br/>Date'),
'index' => 'credit_date',
'width' => '5%'
)
);
After a full re-index & cache refresh, refreshing the page now only displays the column titles and no records. I found that if I rename the column name in the table & magento, it then displays 100%.
What is the reasoning behind this strange behvaior?
-
The table schema is cached even when cache is disabled. Maybe that's it. You need to clear the cache.Marius– Marius2014年01月29日 11:33:06 +00:00Commented Jan 29, 2014 at 11:33
-
@Marius - I did refresh all caches, flushed Magento cache & cache storage as well as JS/CSS cache on top of reindexing all of the tables. The issue persists through this.Moose– Moose2014年01月29日 11:34:10 +00:00Commented Jan 29, 2014 at 11:34
-
1After changing the column type, did you log out? The problem might appear if you have the grid parameters stored in session.Marius– Marius2014年02月21日 06:53:19 +00:00Commented Feb 21, 2014 at 6:53
-
That was indeed the issue @Marius, session persist. Thanks, you can post an answer and I'll accept it.Moose– Moose2014年02月21日 07:19:17 +00:00Commented Feb 21, 2014 at 7:19
1 Answer 1
Based on the discussion in the comments, the error appears because the grid uses saveParametersInSession set to true. The values stored in the session conflict with the database values and column names.
Solution: Log out and re login in the admin panel.