0

I need Layered Navigation Attribute Collection Based on Product Collection.

I have used Following Method it give Attribute List.

$filterableAttributes = $om->get(\Magento\Catalog\Model\Layer\Category\FilterableAttributeList::class);
$appState = $om->get(\Magento\Framework\App\State::class);
$layerResolver = $om->get(\Magento\Catalog\Model\Layer\Resolver::class);
$filterList = $om->create(
\Magento\Catalog\Model\Layer\FilterList::class,
    [
        'filterableAttributes' => $filterableAttributes
    ]
);

$category = 4;

$layer = $layerResolver->get();
$productCollection = $layer->getProductCollection();
$productCollection->addFieldToFilter('application',11);

$layer->setCurrentCategory($category);
$layer->setProductCollection($productCollection);
$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.