Magento 1.4 按类别加载不起作用
我编写了一个 Magento 辅助类,它在 1.3 中运行得非常好。然而,我们正在开发 1.4 的新安装,并且由于某种原因按类别过滤将不起作用。
function __construct() { Mage::app(); $this->model = Mage::getModel('catalog/product'); $this->collection = $this->model->getCollection(); $this->collection->addAttributeToFilter('status', 1);//enabled $this->collection->addAttributeToSelect('*'); } function filterByCategoryID($catID) { $this->collection->addCategoryFilter(Mage::getModel('catalog/category')->load($catID)); }
我不明白为什么这在 1.4 中不起作用。还有其他人参与过这个问题吗?
I have a Magento helper class I wrote that works wonderfully in 1.3. However, we're working on a new install of 1.4 and filtering by category won't work for some reason.
function __construct() { Mage::app(); $this->model = Mage::getModel('catalog/product'); $this->collection = $this->model->getCollection(); $this->collection->addAttributeToFilter('status', 1);//enabled $this->collection->addAttributeToSelect('*'); } function filterByCategoryID($catID) { $this->collection->addCategoryFilter(Mage::getModel('catalog/category')->load($catID)); }
I can't figure out why this isn't working in 1.4. Has anyone else come into this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您发布的内容,我的猜测是您的代码中还有其他内容正在向您的集合添加/删除过滤器。我在 1.4 安装上运行了以下代码
,并且产品集合已按预期进行过滤。
扩展你的问题以显示你如何使用你的助手以及你期望它做什么和它做什么会有所帮助。
Based on what you posted, my guess would be there's something else in your code that's adding/removing filters to/from your collection. I ran the following code on a 1.4 install
and the product collection was filtered as expected.
Expanding your question to show how you're using your helper and what you expect it to do vs what it does would help.
我能够使用下面的代码让它工作......
函数 __construct()
{
法师::app();
}
<代码>
I was able to get it working with the code below...
function __construct()
{
Mage::app();
}