[Magento] Filter product visibility in collection

Posted on 2012-09-17
Last Modified: 2012-10-11
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'
Question by:EddieShipman
    1 Comment
    LVL 26

    Accepted Solution

    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.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Are you using email marketing software? If not, you're missing out on effortless marketing and the reaching of desired conversion rates through email marketing software.
    SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now