I ve been looking around for a good solution to display the store view in a column of my admin grid.
I have the following in my grid
class NsTest_Test_Block_Adminhtml_Testimonial_Grid extends Mage_Adminhtml_Block_Widget_Grid {
...
protected function _prepareCollection()
{
$collection = Mage::getModel('test/testimonial')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
...
I read it is possible to add the store view with this code from some block on internet
$collection = Mage::getModel('tc_storeview/stores')->getResourceCollection();
foreach ($collection as $view) {
if ( $view->getStoreId() && $view->getStoreId() != 0 ) {
$view->setStoreId(explode(',',$view->getStoreId()));
} else {
$view->setStoreId(array('0'));
}
}
But how to use this? I think the code would show the store view, but how about my data.
Is there a way to join both, store and my model ?
Seems like below code is working, still dont really understand how that can work.
class NsTest_Test_Block_Adminhtml_Testimonial_Grid extends Mage_Adminhtml_Block_Widget_Grid {
...
protected function _prepareCollection()
{
$collection = Mage::getModel('test/testimonial')->getCollection();
foreach ($collection as $view) {
if ( $view->getStoreId() && $view->getStoreId() != 0 ) {
$view->setStoreId(explode(',',$view->getStoreId()));
} else {
$view->setStoreId(array('0'));
}
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
Best Answer
for store grind column use below code.
store
is database coulmn namefor
rendering
thestores