[Magento] Filter product visibility in collection

We use this Magento code to get a list of publications to pick 2 from to show in a Bookstore section.
$collection = Mage::getModel('catalog/category')->getCollection();
    ->addAttributeToFilter('is_active', 1)

Open in new window

How can I add an attribute to select to make it not include the publications that are set to "Not show individually"?

If I add this:
->addAttributeToFilter('visibility', 4) // Only catalog, search visiblity

Open in new window

The code fails with message 'Invalid attribute name: visiblity'
LVL 26
Eddie ShipmanAll-around developerAsked:
Who is Participating?
Eddie ShipmanAll-around developerAuthor Commented:
Found that the visibility attribute is not attributable to the catalog collection. It must be placed on the product collection later on in the script when looping through the products.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.