cancel
Showing results for 
Search instead for 
Did you mean: 

get layered navigation programmatically

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

get layered navigation programmatically

Hi,

I want to get Attribute and its item programmatically (Layered navigation), I tried this https://magento.stackexchange.com/questions/262052/magento-2-api-how-to-get-layer-navigation-filters...

but its only showing attribute not items, can anyone help me

3 REPLIES 3

Re: get layered navigation programmatically

Thank you @tom_tyler, I already tried this, It is returning all the attributes which is not in layered navigation (which don't have items).

Re: get layered navigation programmatically

Hey,

this is a while ago but it might help anyone who is looking for it:

 

You would need to do something like this:

$obj = \Magento\Framework\App\ObjectManager::getInstance();

// Attribute - dropdown
$eavConf = $obj->get('\Magento\Eav\Model\Config');

$attr = $eavConf->getAttribute('catalog_product', 'your-attribute');
$aOptions = $attr->getSource()->getAllOptions();
$existingOptions = array(); foreach( $aOptions as $ao ) { $existingOptions[$ao['value']] =strtolower($ao['label']); } error_log("Attribute Options: " . print_r($existingOptions, true));

I hope this is helping Smiley Happy 

 

Re: get layered navigation programmatically