Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

[Magento] Filter product visibility in collection

Posted on 2012-09-17
1
Medium Priority
?
2,413 Views
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();
$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'
0
Comment
Question by:Eddie Shipman
1 Comment
 
LVL 26

Accepted Solution

by:
Eddie Shipman earned 0 total points
ID: 38486736
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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How important is it to take extra precautions to protect your online business? These are some steps you can take to make sure you're free of any cyber crime.
Learn about the eCommerce marketing trends for the year ahead.
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:
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Suggested Courses

564 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