magetno collection filter

piaoling  2011-10-12 16:09:43

 $todayDate  = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
        $this->_getProductCollection()
            ->addAttributeToFilter('news_from_date', array('or'=> array(
                0 => array('date' => true, 'to' => $todayDate),
                1 => array('is' => new Zend_Db_Expr('null')))
            ), 'left')
            ->addAttributeToFilter('news_to_date', array('or'=> array(
                0 => array('date' => true, 'from' => $todayDate),
                1 => array('is' => new Zend_Db_Expr('null')))
            ), 'left')
            ->addAttributeToFilter(
                array(
                    array('attribute' => 'news_from_date', 'is'=>new Zend_Db_Expr('not null')),
                    array('attribute' => 'news_to_date', 'is'=>new Zend_Db_Expr('not null'))
                )
            )
            ->addAttributeToFilter('visibility', array('in' => array(2, 4)))
            ->addAttributeToSort('news_from_date', 'desc')
            ->setPage(1, 4)
        ;

类别 :  magento(258)  |  浏览(3969)  |  评论(0)
发表评论(评论将通过邮件发给作者):

Email: