// 4. Search for the document over the order number of its attached order
$documents = $this->documentRepository->search( (newCriteria()) ->addFilter(newEqualsFilter('order.orderNumber', $order->getOrderNumber())) ->addAssociation('order') ->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_EXACT), $this->context, );