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
2010-09-15 13:14:52
hi jonathan, thanks for always being around to answer my questions, let me give a try, i'll let you know
Kstro21
2010-09-15 13:41:26
i'm working with magento 1.9 ee, category_ids don't exist
Kstro21
2010-09-15 14:12:28
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
2010-09-15 14:20:29
another suggestion
Kstro21
2010-09-15 14:34:59
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
2010-09-15 15:30:39
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
2010-09-16 13:50:58
you're right, meanwhile i'll use this way...let meknow if you find another solution
Kstro21
2010-09-16 20:59:15