0

I have two Product attributes prebook_date and release_date
I want products with prebook_date greater than today's date & prebook_date less than release_date value.

I tried this code to get products which are presale_date greater than today_date

$today_date = date('Y-m-d H:i:s');
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToFilter('prebook_date', array(
        'from' => $today_date,
        'date' => true,
        ));

Any suggestions how to get products which have prebook_date > today_date AND prebook_date < release_date

  • do you save prebook_date and release_date for a book? – Mujahidh Sep 14 '17 at 5:58
0

Your question is little bit confuse. but try some thing greater than and less than like this

$today_date = date('Y-m-d H:i:s');
$collection = Mage::getModel('catalog/product')->getCollection();
$release_date = "Your release Date";
$collection->addFieldToFilter(array(
'prebook_date' => array('gt' => $release_date),
'prebook_date' => array('lt' => $curDate)));

UPDATE

$today_date = date('Y-m-d H:i:s');
$collection = Mage::getModel('catalog/product')->getCollection();
$release_date = "Your release Date";
$collection->addAttributeToFilter('prebook_date', array('gt' => $release_date));
$collection->addAttributeToFilter('prebook_date', array('lt' => $curDate));
  • Thanks @mujahidh In one line: I need products which have prebook_date > today_date AND prebook_date < release_date – Rahul Dadhich Sep 14 '17 at 7:00
  • try my updated answer – Mujahidh Sep 14 '17 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.