cancel
Showing results for 
Search instead for 
Did you mean: 

Custom attribute listing page

Custom attribute listing page

Hello everyone. I have a custom product attribute (brand) and I need to create a brand listing page. I know that I can filter by brand in the products category page (e.g. /category?brand=23) but the same brand could be in products of different categories. How can I display a page with all the products of a specific brand?

2 REPLIES 2

Re: Custom attribute listing page

Hello @Miroir Studio 

 

You need customization for show products of specific "brand"  attribute.
You can take reference from below example code:

Make preference of this class Magento\Catalog\Block\Product\ListProduct

and go to its _getProductCollection() method and put your attribute filter condition after this line

$this->_productCollection = $layer->getProductCollection();

for example

  $this->_productCollection = $layer->getProductCollection();
  $this->_productCollection->addAttributeToFilter('brand', 10);

It may help you!
Thank you.

Problem solved? Click Accept as Solution!

Re: Custom attribute listing page