How get list of customer which bought just once (in the last x month) in Magento?


bought once in last 12 months

bought once in last 9 months

bought once in last 20 months

bought once in last 36 months

  • Bough means donot understand the word? – Amit Bera Jun 22 '18 at 7:26

Try below code

protected function _prepareLayout()
    $searchCriteria = $this->searchCriteriaBuilder

    $to = date("Y-m-d h:i:s"); // current date
    $from = strtotime('-2 day', strtotime($to));
    $from = date('Y-m-d h:i:s', $from); // 2 days before

    $ordersList = $this->orderRepository->getList($searchCriteria);
    $ordersList->addFieldToFilter('created_at', array('from'=>$from, 'to'=>$to));

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.