0

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

Like:

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
0

Try below code

protected function _prepareLayout()
{
    $searchCriteria = $this->searchCriteriaBuilder
      ->addFilter('status','pending','eq')
      ->addSortOrder($this->sortBuilder->setField('entity_id')
      ->setDescendingDirection()->create())
      ->setPageSize(100)->setCurrentPage(1)->create();

    $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));
}
| improve this answer | |

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.