I have to show the list of products added to a particular category on ajax request. So when i tried to use category filter method it shows fatal error. Using magento 1.4.1
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e.category_ids' in 'where clause'' in /var/www/html/wc2/lib/Zend/Db/Statement/Pdo.php:228 Stack trace:
#0 /var/www/html/wc2/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /var/www/html/wc2/lib/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)
#2 /var/www/html/wc2/lib/Zend/Db/Adapter/Abstract.php(468): Zend_Db_Statement->execute(Array) > #3 /var/www/html/wc2/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT count(DI...', Array)
#4 /var/www/html/wc2/lib/Varien/Db/Adapter/Pdo/Mysql.php(333): Zend_Db_Adapter_Pdo_Abstract->query('SELECT count(DI...', Array)
#5 /var/www/html/wc2/lib/Zend/Db/Adapter/Abstract.php(799): Varien_Db_Adapter_Pdo_Mysql->query('SELECT count(DI...', Array)
#6 /var/www/html/wc2/lib/Varien/Data/Collection/Db.php(210): Zend_Db_Adapter_Abstract->fetchOne('SELECT count(DI...', Array)
#7 /var/www/html/wc2/lib/Varien/Data/Collec in /var/www/html/wc2/lib/Zend/Db/Statement/Pdo.php on line 234
This is the code i added on ajax file
$_productCollection = Mage::getModel('catalog/product')->getCollection()
->addPriceData()
->addAttributeToSort('name', 'ASC')
->addAttributeToFilter('category_ids',array('finset'=>'604'))
->addCategoryFilter('category_id','604')
->setPageSize($limit)
->setPage($p, $limit)
->addAttributeToSelect('*');
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->setPageSize($limit)
->setPage($p, $limit)
->addAttributeToFilter('category_ids',array('finset'=>'66,67'));
foreach ($_productCollection as $_product):
echo $_product->getId();
endforeach;
Neither of them working. Both of them showing same error. Please someone help me out. Thanks