2

I've created a new product attribute 'brand'. This attribute is within my default attribute set. Now I'm trying to get all brands from a product collection within a category.

I'm fetching the product collection:

$products = $this->_productCollectionFactory
    ->addAttributeToSelect('brand')
    ->addCategoryFilter($activeCategory)
    ->load();

But the brand is not displayed? The attribute brand is just a simpel text attribute. How can I fetch all brands from this collection?

Thanks

  • did you rebuild the indexes? If you have flat catalog enabled, did you mark the attribute as "used in product listing"? – Marius Feb 29 '16 at 15:58
  • Marius, thanks a lot. The option 'Used in product listing' was the fix! – Silvan Feb 29 '16 at 17:10
5

Based on the comments...
when using an attribute in a product collection, if the flat catalog is enabled, the attribute must be marked as Used in product listing in order to be picked up by the collection.

  • What if flat catalog isn't enabled? – Steve Robbins May 17 '17 at 21:27
  • @SteveRobbins with flat catalog disabled it should work with out any additional actions. – Marius May 18 '17 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.