dongtan7998 2011-02-28 18:53
浏览 55
已采纳

Magento addAttributeToFilter不按照我认为应该的方式工作

I have a product attribute that I have set the scope to website (so in theory it would be different on each website defined).

However for some reason when I use it in an addAttributeToFilter() it seems to ignore it.

Let me show you the code I am using:

$total_products_obj = Mage::getModel('catalog/product')
  ->getCollection()
  ->addAttributeToSelect('*')
  ->addAttributeToFilter('discontinued', array('neq' => 1) )
  ->addAttributeToFilter('video_url', array('notnull' => '') );

The attribute I am having trouble with is the video_url attribute. Like I said it's scope is set to Website where discontinued is a Global attribute.

I have not really done much with Website attributes, is there something else that I need to do in order to get this attribute to not be ignored? Right now I am getting a collection of all the products where discontinued does not equal 1.

  • 写回答

2条回答 默认 最新

  • dongwen1909 2011-05-31 15:50
    关注

    I turned off Use Flat Catalog Product and it started to work as expected.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100