views:

36

answers:

1

I was able to make an ordered list of categories with child products, now i need to add a list of products that are not related to any category

A: 

This should give you what you want:

$collection = Mage::getModel('catalog/product')->getCollection()
                ->addAttributeToFilter('category_ids','');

Cheers, JD

Jonathan Day
hi jonathan, thanks for always being around to answer my questions, let me give a try, i'll let you know
Kstro21
i'm working with magento 1.9 ee, category_ids don't exist
Kstro21
well, i was looking into eav_attribute table and category_ids exist, so, why a get an exception a:5:{i:0;s:79:"SELECT `e`.* FROM `catalog_product_entity` AS `e` WHERE (e.category_ids = '')
Kstro21
another suggestion
Kstro21
your response didn't work, but served me as guide, this work for me, public function getProdNoRelated() { $c = Mage::getModel('catalog/product')->getCollection() ->addAttributeToFilter('name', array('like'=>'%'.$this->getRequest()->getParam('q').'%'));; $temp; foreach($c as $_c){ $_c->load(); $cat = $_c->load()->getCategory_ids(); if(!count($cat)) $temp[]=$_c; } return $temp; }
Kstro21
I'd like to think there is a more efficient soution, having to load each product is likely to perform badly. I'll see what I can find.
Jonathan Day
you're right, meanwhile i'll use this way...let meknow if you find another solution
Kstro21