$order = Mage::getModel('sales/order')->load($orderid);
$Incrementid = $order->getIncrementId();
How to get order increment id using order id?
Question
How can I get order increment id (like 100000028) with order id (like 28). In sales order page order increment id is like 100000028, but I have order id like 28.
How can I get order increment id by order id? I have tried below
$write = Mage::getSingleton('core/resource')->getConnection('core_read');
$result=$write->query("SELECT entity_id FROM `sales_flat_order` WHERE `increment_id` = 'your increment id' ");
$row = $result->fetch();
echo $row['entity_id'];
Solution
OTHER TIPS
The other answers require loading the entire order, which is overkill. You can use this built-in method instead:
Mage::getResourceModel('sales/order')->getIncrementId($orderId)
This will run a simple SELECT
query to fetch just that one field.
Use the following code in order to get Order increment id -
$order = Mage::getModel('sales/order');
$order->load([Enter Order Id]);
$incrementId = $order->getIncrementId();
I use preg_match
, which is easy and simple:
$o_id = preg_match('/10*(.*)/', $row[order_id], $o_id2 );
echo "Your order id is: $o_id2[1]"
As long as your increment id is like 10, it will work.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow