5

I'm trying to find the best way to modify products collection for products grid in admin. In particular, to add additional filter to the collection. I don't want to override the grid's block to achieve that. Looks like I'm stuck and cant find a point to start using DI in this case. Also, I can't find any event for loading grid collection as it was in Magento 1.x If someone has experience in this I would be very appreciate for any info.

4
  • I'm not sure we're really there in terms of separation of concerns, but Magento2 is so different from Magento1 that I feel a need to separate the two entirely. Questions, inquiries... whatever - it all belongs somewhere else as this is an entirely different beast Commented Mar 15, 2015 at 10:18
  • P.s. I raised the concern here: meta.magento.stackexchange.com/questions/541/… feel free to chime in if you want! Commented Mar 15, 2015 at 10:21
  • 2
    @ReidBlomquist it clearly says Magento 2 questions are allowed.
    – mbalparda
    Commented Mar 15, 2015 at 16:15
  • My fault; didn't realize this was the case! Commented Mar 16, 2015 at 15:29

1 Answer 1

4

The easiest way is to create "before" plugin for Magento\Catalog\Block\Adminhtml\Product\Grid::setCollection and make with collection all that you want.

1
  • Yeah, found the same solution. Anyway, thanks for the advice. Commented Mar 24, 2015 at 7:51

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.