1

There is a way to exclude from the count, in the layered navigation, child product that have the filter attribute? For example: I have a product A with attribute region set to "tuscany", and I have also a bundle B which contains the product A, but the bundle doesn't have the region attribute set. What I get in layered navigation for region filter "tuscany" is 2, but I don't want to include in the count the bundle's child items.

1

1 Answer 1

0

I have found a solution: Ive created a plugin on the indexer

<type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer">
    <plugin name="excludeBundleFromCount" type="Vendor\FilteredNavigation\Plugin\Indexer\AbstractIndexer"/>
</type>

and the class:

namespace Vendor\FilteredNavigation\Plugin\Indexer;

class AbstractIndexer
{
    public function aroundGetRelationsByParent(
        \Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer $subject,
        \Closure $proceed,
        $parentIds
    ) {
        return [];
    }
}

so all the save on bundle item doesn't create an index entry for the attribute.

Not the beatiful and elegant way but it does its job.

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.