Skip to main content
protected function _prepareCollection() { $collection = Mage::getModel('mdnews/news')->getCollection(); $this->setCollection($collection); return parent::_prepareCollection(); }
protected function _prepareColumns()
{

    $helper = Mage::helper('mdnews');

    $this->addColumn('news_id', array(
        'header' => $helper->__('News ID'),
        'index' => 'news_id',
        'width' => '100px',
    ));

    $this->addColumn('title', array(
        'header' => $helper->__('Title'),
        'index' => 'title',
        'type' => 'text',
    ));

    $this->addColumn('category', array(
        'header' => $helper->__('Category'),
        'index' => 'category_id',
        'options' => $helper->getCategoriesList(),
        'type'  => 'options',
        'width' => '150px',
    ));

    $this->addColumn('created', array(
        'header' => $helper->__('Created'),
        'index' => 'created',
        'type' => 'date',
    ));

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

    $this->addColumn('news_id', array(
    'header' => $helper->__('News ID'),
    'index' => 'news_id',
    'width' => '100px',
    ));

   $this->addColumn('title', array(
    'header' => $helper->__('Title'),
    'index' => 'title',
    'type' => 'text',
   ));

   $this->addColumn('category', array(
    'header' => $helper->__('Category'),
    'index' => 'category_id',
    'options' => $helper->getCategoriesList(),
    'type'  => 'options',
    'width' => '150px',
   ));

   $this->addColumn('created', array(
    'header' => $helper->__('Created'),
    'index' => 'created',
    'type' => 'date',
   ));

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

    $helper = Mage::helper('mdnews');

    $this->addColumn('news_id', array(
        'header' => $helper->__('News ID'),
        'index' => 'news_id',
        'width' => '100px',
    ));

    $this->addColumn('title', array(
        'header' => $helper->__('Title'),
        'index' => 'title',
        'type' => 'text',
    ));

    $this->addColumn('category', array(
        'header' => $helper->__('Category'),
        'index' => 'category_id',
        'options' => $helper->getCategoriesList(),
        'type'  => 'options',
        'width' => '150px',
    ));

    $this->addColumn('created', array(
        'header' => $helper->__('Created'),
        'index' => 'created',
        'type' => 'date',
    ));

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

    $this->addColumn('news_id', array(
    'header' => $helper->__('News ID'),
    'index' => 'news_id',
    'width' => '100px',
    ));

   $this->addColumn('title', array(
    'header' => $helper->__('Title'),
    'index' => 'title',
    'type' => 'text',
   ));

   $this->addColumn('category', array(
    'header' => $helper->__('Category'),
    'index' => 'category_id',
    'options' => $helper->getCategoriesList(),
    'type'  => 'options',
    'width' => '150px',
   ));

   $this->addColumn('created', array(
    'header' => $helper->__('Created'),
    'index' => 'created',
    'type' => 'date',
   ));

   return parent::_prepareColumns();
}
added 1178 characters in body
Source Link
O.Petrov
  • 175
  • 4
  • 10

I want to add field sort order in admin grid and in frontend part (sort by). I make module "news" and want to sort my news by title.

Please guide me how to do it

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

    $helper = Mage::helper('mdnews');

    $this->addColumn('news_id', array(
        'header' => $helper->__('News ID'),
        'index' => 'news_id',
        'width' => '100px',
    ));

    $this->addColumn('title', array(
        'header' => $helper->__('Title'),
        'index' => 'title',
        'type' => 'text',
    ));

    $this->addColumn('category', array(
        'header' => $helper->__('Category'),
        'index' => 'category_id',
        'options' => $helper->getCategoriesList(),
        'type'  => 'options',
        'width' => '150px',
    ));

    $this->addColumn('created', array(
        'header' => $helper->__('Created'),
        'index' => 'created',
        'type' => 'date',
    ));

    return parent::_prepareColumns();
}

I want to add field sort order in admin grid and in frontend part (sort by). I make module "news" and want to sort my news by title.

Please guide me how to do it

I want to add field sort order in admin grid and in frontend part (sort by). I make module "news" and want to sort my news by title.

Please guide me how to do it

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

    $helper = Mage::helper('mdnews');

    $this->addColumn('news_id', array(
        'header' => $helper->__('News ID'),
        'index' => 'news_id',
        'width' => '100px',
    ));

    $this->addColumn('title', array(
        'header' => $helper->__('Title'),
        'index' => 'title',
        'type' => 'text',
    ));

    $this->addColumn('category', array(
        'header' => $helper->__('Category'),
        'index' => 'category_id',
        'options' => $helper->getCategoriesList(),
        'type'  => 'options',
        'width' => '150px',
    ));

    $this->addColumn('created', array(
        'header' => $helper->__('Created'),
        'index' => 'created',
        'type' => 'date',
    ));

    return parent::_prepareColumns();
}
Source Link
O.Petrov
  • 175
  • 4
  • 10

Add field "sort order"

I want to add field sort order in admin grid and in frontend part (sort by). I make module "news" and want to sort my news by title.

Please guide me how to do it