$_productCollection = $block->getLoadedProductCollection(); $_productCollection->clear() ->addAttributeToFilter('author', array('eq' => 'Author-1')) ->load(); $this->setCollection($_productCollection);
I would suggest taking a different approach to leverage native Magento functionality with custom filterable attributes.
After double-checking the attribute settings are compatible, for example that the
author attribute's setting is configured to enable it as a
filterable attribute, then change the way that you are handling the product listing so that native Magento functionality will handle proper product collection filtering when filtered by
author. If you are attempting to filter per a specific author, you can do rewrites, or create custom pages that pre-apply the filter by simple url parameters.
Review attribute creation and usage:
Side note: You are obtaining a loaded product collection from a block, then setting it within
$this. I'm certain that there are different code approaches that must be taken before and after the collection has been loaded. I am unsure if a loaded collection can simply be cleared, then work properly with
addAttributeToFilter(...) method. I would think that even if it does work, you would still want to