#StackBounty: #magento2 #layered-navigation #grouped-products Grouped Products: Filter based on simple products

Bounty: 100

The problem

I’m currently building a Magento 2 store which sells items in boxes and as singles (eg. a single item or a sealed box of 12). The product page has a grid which lets you add any number of boxes and any number of singles to your basket in one go.

I’ve currently got this set up with grouped/simple products – one product called FOO-GROUP which is placed into the relevant categories (but not given any attributes such as colour, size, etc) then individual products called FOO-L-ONE, FOO-L-BOX, FOO-M-ONE and so on which have the attributes set on them.

Grouped products are set to show up in Catalog and Search, while the simple products are set not to show up individually.

The problem is that on the category listing page, there are no filters for colour, size, price etc. because the grouped products don’t have those attributes – the simple products do, but those simple products are set not to show in the catalog listing.


The planned solution

I’m trying to find where the layered navigation gets its products from, then iterate over those products to check if each one is a grouped product. If so, I’d like to inject its child products instead of the group.

I’ve found a Magento.SE post which seems to be doing the same thing for Magento 1, but can’t find anything on how to do this in Magento 2. I’ve looked through the Layered Navigation module, the Catalog module and the Grouped Product module but not been able to figure out what I need to change where.


Help

There are two ways this could go (that I can think of).

I might be trying to do this the correct way and not being able to find the right bit of code – if so, any suggestions on where I should be looking are much appreciated.

It’s also entirely possible that I’m doing something fundamentally wrong, and perhaps shouldn’t be using grouped products or shouldn’t be doing something else that I am. If that’s the case, please suggest how you’d set up the same situation and I can try that.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.