2

I've been able to add columns to the sales order grid table in admin, but when I try to use the column to search I get an error Strict Notice: call_user_func() expects parameter 1 to be a valid callback, non-static method filterSkus() should not be called statically

Here's the observer function

public function filterSkus($collection, $column)
{
    if (!$value = $column->getFilter()->getValue()) {
        return $this;
    }

    $collection->getSelect()->having(
        "group_concat(`m_sales_flat_order_item`.sku SEPARATOR ', ') like ?", "%$value%");

    return $this;
}

Here's the data helper calling it

public function getSkusColumnParams()
{
    return array(
        'header' => 'SKUs',
        'index' => 'skus',
        'type' => 'text',
        'filter_condition_callback' => array('DR_Salesgridder_Model_Observer', 'filterSkus'),
    );
}

The stack error is coming from call_user_func in Mage/Adminhtml/Block/Widget/Grid.php

protected function _addColumnFilterToCollection($column)
{
    if ($this->getCollection()) {
        $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
        if ($column->getFilterConditionCallback()) {
            call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
        }

I made the filterSkus function static, but it gives me the error undefined variable: this. Beyond removing the strict reporting, is there another way?

1 Answer 1

2

Use the observer instance, replacing

array('DR_Salesgridder_Model_Observer', 'filterSkus'),

with

array(Mage::getSingleton('salesgridder/observer'), 'filterSkus'),

(you might need to change the class alias "salesgridder/observer" based on your configuration

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.