2010-11-23 4 views
0

je dois montrer la liste des produits ajoutés à une catégorie particulière sur demande ajax. Donc, quand j'ai essayé d'utiliser la méthode de filtrage de catégorie, il montre une erreur fatale. En utilisant magento 1.4.1filtre catégorie 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

Voici le code i ajouté le fichier ajax

$_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; 

Aucun d'entre eux travaillent. Les deux montrant la même erreur. S'il vous plaît quelqu'un m'aider. Merci

Répondre

3
$category = Mage::getModel('catalog/category')->load(604); 

$_productCollection = Mage::getModel('catalog/product')->getCollection() 
->addPriceData()  
->addAttributeToSort('name', 'ASC') 
->addCategoryFilter($category) 
->setPageSize($limit) 
->setPage($p, $limit)  
->addAttributeToSelect('*'); 

Ce filtre devrait fonctionner.

Questions connexes