1

I created my own collection with custom data. This is part from my grid class:

 my grid class extends Mage_Adminhtml_Block_Widget_Grid
 ...
 $this->setCollection($collection);
 array_walk($data['data'], function($order) use (&$collection) {
            $collection->addItem(new Varien_Object([
                'store_id' => $order['store_reference'],
                'shipping_date' => $order['shipping_date'],
                'order_reference' => $order['order_reference'],
                'customer_reference' => $order['customer_reference'],
                'updated_at' => $order['updated_at'],
                'shipping_fullname' => "{$order['shipping_firstname']} {$order['shipping_middlename']} {$order['shipping_lastname']}",
            ]));
        });
        $collection->setCurPage($page);
        $collection->setLastPageNumber($lastPage);
        $collection->setSize($lastPage * $limit);

        $this->setCollection($collection);
        return $this;

where $collection is an instance of class which extends Varien_Data_Collection. The content of that class is:

    protected $hardSetSize = 1;
    protected $setLastPageNumber = 1;
    /**
     * @param int $size
     */
    public function setSize(int $size)
    {
        $this->hardSetSize = $size;
    }
    /**
     * Retrieve collection all items count
     *
     * @return int
     */
    public function getSize()
    {
        return $this->hardSetSize;
    }

    public function setLastPageNumber(int $lastPage)
    {
        $this->setLastPageNumber = $lastPage;
    }

    public function getLastPageNumber()
    {
        return $this->setLastPageNumber;
    }

My grid is displayed, I got my custom data. But there is filtering problem. I created my column like:

    $this->addColumn('store_id', [
        'header'    => Mage::helper('ffm_fulfillment')->__('Store'),
        'align'     => 'left',
        'index'     => 'store_id',
        'renderer'  => 'Mynamespace_Mymodule_Block_Adminhtml_Test_Grid_Renderer_Store',
        'filter_condition_callback' => [$this, '_storeFilter'],
    ]);

I got the render data, which are store ids from 1-20. I want to filter them. I created my _storeFilter function. What should I do next ? I put a message and the exit() in my function and on filtering I do not get my message.

protected function _storeFilter($collection, $column)
{
    $value = $column->getFilter()->getValue();
    echo 'Test'; exit();
}

1 Answer 1

0

I have checked your mentioned code and found you have wrong defined 'filter_condition_callback' => [$this, '_storeFilter'],

From
'filter_condition_callback' => [$this, '_storeFilter'],
To
'filter_condition_callback' => array($this, '_storeFilter'),

For more information you can follow the below post https://stackoverflow.com/questions/29732847/how-to-create-filter-condition-callback-on-custom-renderer-in-magento-admin-grid

1
  • Nope, is not that I tried both ways, still did not get my message :) . Thank you Commented Aug 29, 2017 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.