- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2019
11:50 PM
07-21-2019
11:50 PM
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
Labels:
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019
03:50 AM
07-22-2019
03:50 AM
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).
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2021
08:15 AM
06-17-2021
08:15 AM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2021
01:24 AM
09-11-2021
01:24 AM