Consider my 'shorts' category below. It has 149 products in. 13 are configurable, the rest are simple products that have a visibility of 'Not visible individually'.

Category listing in admin

I have the following:

$category = $this->categoryRepositoryFactory->create();
$category = $category->get(20);

$collection = $this->productCollectionFactory->create();
$collection->addAttributeToFilter('visibility', [1,2,3,4]);

This only retrieves the 13 records with the Configurable products with visibility of 'Catalog, Search'.

(It also doesn't order by position, but that's another matter)

I want to get a list of ALL of the products in the category - Not visible included.

I have tried reindexing, cache etc, but no luck.


Your Answer

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

Browse other questions tagged or ask your own question.