Last active
July 1, 2018 10:46
-
-
Save webdawe/93f07d23aac99e2b46a4c49c492f4cb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Magento 2 | |
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory, | |
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone | |
$currentDate = $this->_timezone->date()->format('Y-m-d H:i:s'); | |
$collection = $this->_productCollectionFactory->create(); | |
$collection->addAttributeToFilter('expiry_date', array('or'=> array( | |
0 => array('date' => true, 'from' => $currentDate), | |
1 => array('null' => true)) | |
), 'left'); | |
//Magento 1 | |
$currentDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT); | |
$productCollection->addAttributeToFilter('expiry_date', array('or'=> array( | |
0 => array('date' => true, 'from' => $currentDate), | |
1 => array('is' => new Zend_Db_Expr('null'))) | |
), 'left') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment