0

I used the below code and list out all the attribute options by current category wise. But, I want to list out available attribute options by selected attribute option with product results. In my case, some attribute option products count ZERO.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
             $filterableAttributes = $objectManager->getInstance()->get(\Magento\Catalog\Model\Layer\Category\FilterableAttributeList::class);
             $layerResolver = $objectManager->getInstance()->get(\Magento\Catalog\Model\Layer\Resolver::class);
             $filterList = $objectManager->getInstance()->create(
                \Magento\Catalog\Model\Layer\FilterList::class,
                    [
                        'filterableAttributes' => $filterableAttributes,
                        'store_id'=>'1'
                    ]
                );
            $layer = $layerResolver->get();
            $layer->setCurrentCategory($category); 
            $filters = $filterList->getFilters($layer);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.