Does anyone know how to get an array with the number of products grouped by attributes that can be filtered, in a controller o helper? For example:
["Activity" => [....], "GENDER" => ["MEN" => 5, "WOMEN" => 5, "UNISEX" => 1] ...]
i am trying to use \Magento\Catalog\Model\Layer\FilterList::getFilters()
but throw
use \Magento\Catalog\Model\Layer\FilterList;
class Magento extends Base {
protected $_filterList;
public function __construct(FilterList $filterList) {
$this->_filterList = $filterList;
}
Fatal error: Uncaught Error: Cannot instantiate interface Magento\Catalog\Model\Layer\FilterableAttributeListInterface in C:\xampp\apps\magento\htdocs\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php:93 Stack trace: #0 C:\xampp\apps\magento\htdocs\vendor\magento\framework\ObjectManager\Factory\Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\Catalog...', Array) #1 C:\xampp\apps\magento\htdocs\vendor\magento\framework\ObjectManager\Factory\Compiled.php(130): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Catalog...')
2 C:\xampp\apps\magento\htdocs\vendor\magento\framework\ObjectManager\Factory\Compiled.php(67):
Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Catalog...')
3 C:\xampp\apps\magento\htdocs\vendor\magento\framework\ObjectManager\Factory\Compiled.php(130):
Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Catalog...')
4 C:\xampp\apps\magento\htdocs\vendor\magento\framework\ObjectManager\Facto
in C:\xampp\apps\magento\htdocs\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php on line 93