Magento 1.4.1 类别过滤器

发布于 2024-10-04 05:07:57 字数 1996 浏览 2 评论 0原文

我必须根据 ajax 请求显示添加到特定类别的产品列表。因此,当我尝试使用类别过滤方法时,它显示致命错误。使用magento 1.4.1

致命错误:未捕获的异常 带有消息的“PDOException” 'SQLSTATE[42S22]:未找到列: 1054 未知列 'e.category_ids' 在“where 子句”中 /var/www/html/wc2/lib/Zend/Db/Statement/Pdo.php:228 堆栈跟踪:
#0 /var/www/html/wc2/lib/Zend/Db/Statement/Pdo.php(228): PDO语句->执行(数组)
#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->执行(数组)> #3 /var/www/html/wc2/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT 计数(DI...',数组)
#4 /var/www/html/wc2/lib/Varien/Db/Adapter/Pdo/Mysql.php(333): Zend_Db_Adapter_Pdo_Abstract->query('SELECT 计数(DI...',数组)
#5 /var/www/html/wc2/lib/Zend/Db/Adapter/Abstract.php(799): Varien_Db_Adapter_Pdo_Mysql->查询('SELECT 计数(DI...',数组)
#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 在 /var/www/html/wc2/lib/Zend/Db/Statement/Pdo.php 在第 234 行

这是我在 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;

它们都不起作用。他们都显示相同的错误。请有人帮助我。 谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2024-10-11 05:07:58
$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('*');

这个过滤器应该可以工作。

$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('*');

This filter should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文