Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Category Collections not working with Flat Category turned on
 
holtr94
Jr. Member
 
Total Posts:  1
Joined:  2011-08-02
 

I have this line of code in my site:

$collectionids=Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('someAttribute'$valueToLookFor)->addAttributeToFilter('anotherAttribute'"constant")->getAllIds();

With Flat Category turned off the correct category ids are stored in $collectionids. When it is turned on nothing is returned (verified using xdebug). The attributes are custom attributes and I have verified they exist in the “catalog_category_flat_store_*” tables. Other categories are selected fine, as long as they do not use a filter. Thanks in advance for any help.

EDIT: I did some more deep debugging and it looks like the magento core is only checking the catalog_category_flat_store_1 table, and not the other 11 that exist. This is the query being used:

SELECT `main_table`.`entity_idFROM `catalog_category_flat_store_1` AS `main_tableWHERE (someAttribute 'valueToLookFor') AND (anotherAttribute 'constant')

Is this a Magento core bug, or am I missing something?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top