Fixing Magento Invalid attribute name issue after SUPEE-11219

Fixing Magento Invalid attribute name issue after SUPEE-11219

Having recently updated a Magento installation to apply SUPEE-11219, there were issues when searching for products using the filters for the grid.  I had an error message of:

Invalid attribute name: blcg_custom_field_2

The only reference to 'blcg_custom_field_' was a constant:

const GRID_COLUMN_CUSTOM_GRID_ALIAS = 'blcg_custom_field_';

On line 40 of app/code/community/BL/CustomGrid/Model/Grid.php

This constant is only used within the CustomGrid area above which gives the area to look for the issue, in theory.  The trouble is, this only gets called as a method of itself, and isn't static, so we need to see where in the entire installation the class is used.  There's 469 counts of this, according to PhpStorm.  After cross-referencing the files with the stack trace which is available as part of the output, I traced the issue to the file 'app/code/core/Mage/Adminhtml/Block/Widget/Grid.php' which was updated by the Magento patch.

Around line 467, changing

if (
    $column->getFilterConditionCallback() && 
    $column->getFilterConditionCallback()[0] instanceof self
    ) {
    call_user_func(
        $column->getFilterConditionCallback(),
        $this->getCollection(),
        $column
    );
} else {

to

if (
    $column->getFilterConditionCallback()
    ) {
    call_user_func(
        $column->getFilterConditionCallback(),
        $this->getCollection(),
        $column
    );
} else {

corrected the issue.  I also cleared the Magento cache and rebuilt indexes following advice from StackOverflow, but this had no impact without the change above being in place.