4

I have a custom module with a backend grid and an edit form. In the edit form I have some tab one contains a grid for associated products.

I have implemented the grid int the tab using the code from the products grid for related products.

Now everything seems to work and checkbox are selected according to data from collection.

The only issue is related to the filter Yes/No/Any that doesn't work:
setting the filter to "yes" I have an empty grid, instead if I set the filter to "No/Any" I can see all the products and also the product selected.

So it looks like some association to between the filter and the field name are missed

3
  • Can you post your code, particularly snippets from _prepareColumns and your _prepareColumns? A Magento version number may help as well.
    – B00MER
    Commented Feb 4, 2013 at 17:48
  • Did you find a solution here and the problem? Please share it! Commented May 6, 2013 at 8:15
  • I have reimplemented all code using another product grid as example and now it works
    – Fra
    Commented May 6, 2013 at 9:36

1 Answer 1

3

On the webguys page is a german article about this problem: http://www.webguys.de/magento/turchen-23-pimp-my-produktgrid/

Nicht alle unsere Änderungen werden von Magento übernommen, zum Beispiel funktioniert die Sortierung und Filterung der neuen Attribute nicht.

Das liegt daran, dass unsere Änderungen nach dem Aufruf von _prepareCollection(), in dem die Spalteninfos an die Collection übergeben werden, stattfinden.

Translation:

Not all changes are made by magento, e.g. sorting and filtering of the new attributes doesn't work.

That's because they are made after the _prepareCollection() call, where the informations about the columns are passed to the collection.

protected function _callProtectedMethod($object, $methodName) {
    $reflection = new ReflectionClass($object);
    $method = $reflection->getMethod($methodName);
    $method->setAccessible(true);
    return $method->invoke($object);
}

protected function _modifyProductGrid(Mage_Adminhtml_Block_Catalog_Product_Grid $grid) {
 
    $this->_addUpdatedAtColumn($grid);
    $this->_addColorColumn($grid);
 
    $this->_removeColumn($grid, 'set_name');
    $this->_removeColumn($grid, 'visibility');       

    // reinitialisiert die Spaltensortierung
    $grid->sortColumnsByOrder();
    // reinitialisiert die Sortierung und Filter der Collection
    $this->_callProtectedMethod($grid, '_prepareCollection');               

} 

More in the post. I think the source code is quite self explaining and if not, use google (if you don't understand german ;-))

1
  • I'm just checking out this approach with Observer and Reflection call
    – Fra
    Commented May 22, 2013 at 7:48

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.