$myattr = $this->catalogSession->getData('myattribute');
if(!empty($myattr)){
$collection = $this->_catalogLayer->getProductCollection();
$attribute = $this->eavConfig->getAttribute('catalog_product', 'myattribute');
$option_id = $attribute->getSource()->getOptionId($myattr);
$collection->addAttributeToFilter('myattribute',array('finset'=>$option_id));
}
in Block/Category/MyattributeChooser.php in the _prepareLayout function
This works if I have caching disabled OR I select any filter at all. It does not work if caching is enabled but I used my custom chooser and no other filters are displayed.
I need to know how to make it work. This is on a categories page. I could just totally turn off caching for the chooser but that isn't a very good answer.
I've found too that although it works it doesn't recalculate pagination either. $collection->getSize() results in an Illegal State error and $collection->clear() and $collection->resetData() have no effect on anything whatsoever. $collection->isLoaded() returns NULL.