2

I have created an expiry_date attribute in admin. I have chosen expiry date some products 31-12-2017.My requirement is expiry date ending before one month(30-11-2017) products display.I don't know how to implement this task.Can you please help me?

2 Answers 2

0

Try this in your product collection

$currentDate = Mage::getModel('core/date')->gmtDate('Y-m-d');
$plusOneMonth = date('Y-m-d', strtotime($currentDate . "+1 months"));

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addFieldToFilter('expiry_date', array('from' => $currentDate, 'to' => $plusOneMonth));
10
  • Hi @ Dinesh Yadav, Thank you. Where this code added.Please tell me file path?. Commented Nov 30, 2017 at 6:06
  • Where you want to show your products? Do you want to implement this filter on category page? Commented Nov 30, 2017 at 6:07
  • My requirement is to display products expiry date ending before one month. I have a display that products in table format through programmatically.Can you please help me? Commented Nov 30, 2017 at 6:09
  • I have to save the file into Magento root folder .Show my products in the frontend.Can you please help me? Commented Nov 30, 2017 at 6:12
  • I want to display on the table, Product name,sku, Expiry date in the front end.Can you please help me? Commented Nov 30, 2017 at 6:13
0

I know it is a very old question but we also had a similar requirement because we sell supplement products with expiry date. We searched online and found the following extension which helped us -:

Magento 2 Product Shelf Life

Hope it helps you or other store owners who sell products with limited shelf life or expiry date

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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