I'm currently looking for a method from which I can get the order status based on the order id
, customer email
and customer last name
.
I'd written this code so far
public function orderHistoryAction(){
$req = $this->getRequest();
$oid = $req->getParam('oid', '');
$lnm = $req->getParam('lnm', '');
$eml = $req->getParam('eml', '');
$order = Mage::getModel('sales/order')->loadByIncrementId($oid);
if ($order->getId()) {
if ((strcasecmp($lnm, $order->getCustomerLastname()) == 0) && (strcasecmp($eml, $order->getCustomerEmail()) == 0)) {
echo $order->getStatusLabel();
} else {
echo 'invalid';
}
} else {
echo 'invalid';
}
}
and is working well for both customer and guest. But this doesn't seems to me the right approach. I supposed to used something like written in this blog or this blog. If anybody could make me correct?
Best Answer
If you want to use collections you can get your order object like this:
But it's kind of the same thing that you did.
I even thing your approach is faster.
In your case you run a select like this.
In the approach I described you run something like this:
There is no need for the additional conditions since the
increment_id
must be unique.