2

I would like to know. How can i filter collection by attributes specially When Catalog Input Type for Store Owner is DATE.

Each product will have a future date when there stock will be set as out of stock no matter what is stock qty. And i want to pragmatically set this by filter product based on that future date if future date match with any product that product will set as out of stock. I just dont know how can filter product based on a future date where i can check if its match with that date or not. I hope you understand.

closed as too broad by Jai, Muhammad Hasham, Shoaib Munir, saravanavelu, Manashvi Birla May 28 at 5:40

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

In Your Collection You Can Apply Date Filter Using Start to End Date :-

$fromDate = date('Y-m-d H:i:s', strtotime('-1 hour')); //Start Date
$toDate = date('Y-m-d H:i:s', strtotime(now()));       // End Date
$collection->addFieldToFilter('your_attribute', array(
    'from' => $fromDate,
    'to' => $toDate,
    'date' => true,
    ));  
  • I am not trying to filter from created date. I am trying to filter by a attribute which type is date. – xtremprovider May 28 at 9:33
  • yes you will replace created_at to your attribute – Rk Rathod May 28 at 9:37
  • Aha thats right but this is what i want to achieve. The date attribute will have future date and i want to filter collection whatever match with future date. – xtremprovider May 28 at 10:22
  • please explain clearly you hve 1 attribute "future_date" – Rk Rathod May 28 at 10:23
  • you can filter using "future_date" attribute ??? – Rk Rathod May 28 at 10:24

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