Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8622993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:10:48+00:00 2026-06-12T07:10:48+00:00

We use this Magento code to get a list of publications to pick 2

  • 0

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();

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

The code fails with message ‘Invalid attribute name: visiblity’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:10:49+00:00Added an answer on June 12, 2026 at 7:10 am

    Visibility is a product attribute, not a category attribute. To get products that only have a visibility of 4, you need to get a product collection and traverse over it to get a definitive list of categories:

    $categories = array();
    $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('visibility', 4);
    foreach($products as $product){ 
      foreach($product->getCategoryIds() as $cat){
         $categories[] = $cat;
      }
    }
    
    $categories = array_values(array_unique($categories));
    

    Now, with the $categories array populated with our unique list of categories, we can load only those categories:

    $cat = Mage::getModel('catalog/category')->getCollection()->addIdFilter($categories);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i use this line of code : [self parseXMLFileAtURL:url]; And i get this error
How to call the following two lines in magento's \app\code\core\Mage\Wishlist\Helper\Data.php file $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); Actually
I use this code : MethodInvoker TileLoadCompleteMethodInvoker = delegate() { CleanStatusLabelTimer.Enabled = true; MemoryTextBox.Text
i use this code in my app. just found is not correct when compare
I have this file from the theme of my Magento store: http://www.princessly.com/js/jquery/jquery-1.4.2.min.js And someone
I am trying to find out the default store code from within Magento's backend.
I use this code on my CMS home page to display all the products
use this website a lot but first time posting. My program creates a number
I use this function for transforming URLs to images on output. function InsertLink(T){ var
I use this script in two different servers: function curlGetFileInfo($url, $cookies=default){ global $_config; $ch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.