gpt4 book ai didi

magento - 如何比较 Magento 查询中的两个字段?

转载 作者:行者123 更新时间:2023-12-05 00:02:27 24 4
gpt4 key购买 nike

我正在使用我在某处找到的此代码获取所有事件的特殊产品:

  $collection = $this->_addProductAttributesAndPrices($collection)
->addStoreFilter()
->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $todayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')
->setPageSize($this->get_prod_count())
->setCurPage($this->get_cur_page());

现在我只想得到特价<=价格的产品,但我仍然不知道如何去做。

我一直在阅读此页面: http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/using_collections_in_magento

我试过这个没有成功:
     ->addAttributeToFilter('special_price', array('lt' => 'price'))

谢谢你的帮助!

最佳答案

你可以试试this ,感谢 Zyava!

在我的情况下:

->addAttributeToFilter('price', array ('gt' => new Zend_Db_Expr('final_price') ) )

关于magento - 如何比较 Magento 查询中的两个字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8054418/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com