I just want add a custom function in layered navigation block MagentoLayeredNavigationBlockNavigation
the function :
public function getActiveFilters()
{
$filters = $this->getLayer()->getState()->getFilters();
if (!is_array($filters)) {
$filters = [];
}
return $filters;
}
ive tried to create custom module to override block with preferences as well as plugin, but no luck its not working.
at first try, im using preference. I use this code in
VendorModuleetcdi.xml
< ?xml version="1.0"?>
and create block in my custom module
< ?php
namespace VendorModuleBlock;
class Navigation extends MagentoLayeredNavigationBlockNavigation
{
/**
* Retrieve active filters
*
* @return array
*/
public function getActiveFilters()
{
$filters = $this->getLayer()->getState()->getFilters();
if (!is_array($filters)) {
$filters = [];
}
return $filters;
}
}
but its not working, as well as using plugin to override block.
am I missing something?
and what is the best way to override block?
Thanks in Advance.