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
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).
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