добавить столбец фильтра SELECT в меню сетки - PullRequest
2 голосов
/ 18 февраля 2011

Я пытаюсь добавить select в моем столбце «Sources», чтобы разрешить фильтр, весь этот код работает хорошо, но я пытаюсь добавить фильтр без какого-либо успеха, кто-нибудь может указать мне правильное направление?

Пока не знаю, у меня есть:

protected function _prepareCollection()
{
    $collection = Mage::getResourceModel('customer/customer_collection')
        ->addNameToSelect()
        ->addAttributeToSelect('email')
        ->addAttributeToSelect('created_at')
        ->addAttributeToSelect('group_id')
        ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
        ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
        ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
        ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
        ->joinAttribute('source', 'customer/source', 'default_billing', null, 'left')
        ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');

    $this->setCollection($collection);

    return parent::_prepareCollection();
}

и

$this->addColumn('source', array(
        'header'    => Mage::helper('customer')->__('Source'),
        'type'      => 'source',
        'index'     => 'source'
    ));

Любая помощь будет очень признательна, спасибо

Ответы [ 2 ]

2 голосов
/ 28 февраля 2011

Я нашел решение для преобразования в a Выберите параметр:

$sql = 'SELECT distinct value FROM `....';
$data = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchAll($sql);

$soTypes=array();
foreach($data as $array){
  foreach($array as $key => $value){
    if(!empty($value)){
      $so[$value]=$value;
    }
  }
}

$this->addColumn('invoice_so', array(
    'header'    => Mage::helper('sales')->__('SoTypes'),
    'index'     => 'value',
    'width'     => '100px',
    'type'      => 'options',
    'options' => $soTypes,
));
0 голосов
/ 18 февраля 2011

Типовое значение не должно быть source. Это ничего не делает. Это должен быть один из классов в app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/.

  • Checkbox
  • Страна
  • Дата
  • Datetime
  • Massaction
  • Цена
  • Радио
  • Диапазон
  • Выберите
  • Магазин
  • Текст
  • Тема
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...