0

Magento grid filter_condition_callback ignored? in Magento ver. 1.9.4.3

Help appreciated! Stuck ;)

We added a column to both the order and the product grid. This works fine. We then added a filter_condition_callback .. this has worked for years

Recently we updated to Magento ver. 1.9.4.3 the LTS version found here https://github.com/OpenMage/magento-lts

Since then filter_condition_callback seems to be completely ignored. We added an EXIT cluase in the method but nothing happens!

This is our code


            $block->addColumnAfter('warehouse',
                array(
                    'header' => Mage::helper('safemage_multiinventory')->__('Warehouse'),
                    'type'  => 'options',
                    'sortable' => false,
                    'index' => 'main_table.warehouse_ids',
                    'options' => $this->getActiveWarehousesArray(),
                    'frame_callback' => array($this, 'showWarehouseInOrder'),
                    'filter_condition_callback' => array($this, 'filterOrderWarehouseCondition'),
                    'width' => '120px'
                ),
                'shipping_name'
            );

and


    public function filterOrderWarehouseCondition($collection, $column)
    {
        if (!$value = $column->getFilter()->getValue()) {
            return $this;
        }
        $select = $collection->getSelect();
        $select->joinLeft(
            array('warehouse_filter_tbl' => $collection->getTable('safemage_multiinventory/warehouse_order_item')),
            'warehouse_filter_tbl.order_id = main_table.entity_id AND warehouse_filter_tbl.qty <> 0',
            array());

        $collection->addFilter('warehouse_filter_tbl.warehouse_id', array('in' => $value));

        return $this;

    }

question: what is going on here and why is the callback method ignored? The strange thing is that we have other grids where the same callback seems to be accessed ... and here it works fine? duh??!

Tips and ideas welcome ;)

https://stackoverflow.com/questions/32222310/magento-invoice-grid-filter-condition-callback-not-working

complete trace, but here it can be seen that Magento makes no effort to find and use the filter_condition_callback


invalid attribute name: warehouse_ids

#0 app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(1295): Mage::exception('Mage_Eav', 'Invalid attribu...')
#1 app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(1388): Mage_Eav_Model_Entity_Collection_Abstract->_addAttributeJoin('warehouse_ids', 'inner')
#2 app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(322): Mage_Eav_Model_Entity_Collection_Abstract->_getAttributeConditionSql('warehouse_ids', Array, 'inner')
#3 app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php(1446): Mage_Eav_Model_Entity_Collection_Abstract->addAttributeToFilter('warehouse_ids', Array, 'inner')
#4 app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(342): Mage_Catalog_Model_Resource_Product_Collection->addAttributeToFilter('warehouse_ids', Array)
#5 app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(472): Mage_Eav_Model_Entity_Collection_Abstract->addFieldToFilter('warehouse_ids', Array)
#6 app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php(142): Mage_Adminhtml_Block_Widget_Grid->_addColumnFilterToCollection(Object(Mage_Adminhtml_Block_Widget_Grid_Column))
#7 app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(457): Mage_Adminhtml_Block_Catalog_Product_Grid->_addColumnFilterToCollection(Object(Mage_Adminhtml_Block_Widget_Grid_Column))
#8 app/code/community/BL/CustomGrid/Model/Grid/Rewriter/Eval.php(39) : eval()'d code(88): Mage_Adminhtml_Block_Widget_Grid->_setFilterValues(Array)
#9 app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(534): BL_CustomGrid_Block_Rewrite_Mage_Adminhtml_Block_Catalog_Product_Grid->_setFilterValues(Array)
#10 app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php(125): Mage_Adminhtml_Block_Widget_Grid->_prepareCollection()
#11 app/code/community/BL/CustomGrid/Model/Grid/Rewriter/Eval.php(39) : eval()'d code(107): Mage_Adminhtml_Block_Catalog_Product_Grid->_prepareCollection()
#12 app/code/community/BL/CustomGrid/Model/Grid/Rewriter/Eval.php(39) : eval()'d code(434): BL_CustomGrid_Block_Rewrite_Mage_Adminhtml_Block_Catalog_Product_Grid->_prepareCollection()
#13 app/code/community/BL/CustomGrid/Model/Observer.php(500): BL_CustomGrid_Block_Rewrite_Mage_Adminhtml_Block_Catalog_Product_Grid->blcg_finishPrepareCollection()
#14 app/code/community/BL/CustomGrid/Model/Grid/Rewriter/Eval.php(39) : eval()'d code(104): BL_CustomGrid_Model_Observer->afterGridPrepareCollection(Object(BL_CustomGrid_Block_Rewrite_Mage_Adminhtml_Block_Catalog_Product_Grid))
#15 app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(644): BL_CustomGrid_Block_Rewrite_Mage_Adminhtml_Block_Catalog_Product_Grid->_prepareCollection()
#16 app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(651): Mage_Adminhtml_Block_Widget_Grid->_prepareGrid()
#17 app/code/core/Mage/Core/Block/Abstract.php(926): Mage_Adminhtml_Block_Widget_Grid->_beforeToHtml()
#18 app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#19 app/code/core/Mage/Core/Block/Abstract.php(927): Mage_Core_Block_Text_List->_toHtml()
#20 app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#21 app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#22 app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php(307): Mage_Core_Controller_Varien_Action->renderLayout()
#23 app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Catalog_ProductController->gridAction()
#24 app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('grid')
#25 app/code/core/Mage/Core/Controller/Varien/Front.php(174): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#26 app/code/core/Mage/Core/Model/App.php(381): Mage_Core_Controller_Varien_Front->dispatch()
#27 app/Mage.php(745): Mage_Core_Model_App->run(Array)
#28 index.php(109): Mage::run('STORENAME', 'store')
#29 {main}

3

2 Answers 2

0

@snh_nl this PR did not went in, it should be fixed on client/module side ...see SUPEE-11219 Potential issues?

Also for OpenMage you have to fix your code!

-1

There was a code breaking change

Read

https://github.com/OpenMage/magento-lts/issues/882

And apply

https://github.com/OpenMage/magento-lts/pull/887

Your Answer

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

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