[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();
$collection->addAttributeToSelect('url_key')
    ->addAttributeToSelect('name')
    ->addAttributeToSelect('id')
    ->addAttributeToSelect('description')
    ->addAttributeToSelect('is_anchor')
    ->addAttributeToFilter('is_active', 1)
    ->joinUrlRewrite()
    ->load();

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.
0
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.