How to get last running transaction Id in magento
How can I get the last running transaction Id ? (eg: 10000001) I've tried numerous ways, with no succes开发者_C百科s.
I was suddenly enlightened when I looked at the problem again at home. Why not get the last order increment id from the sales/order collection?
$orders = Mage::getModel('sales/order')->getCollection()
->setOrder('increment_id','DESC')
->setPageSize(1)
->setCurPage(1);
echo $orders->getFirstItem()->getIncrementId();
Tested and working on Magento 1.3.2.3
Try this:
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$dbc_collect_order = Mage::getSingleton('core/resource')->getConnection('core_read');
$items_collect_order = $dbc_collect_order->fetchAll("SELECT `increment_id` FROM `sales_flat_order` ORDER BY `entity_id` DESC LIMIT 1");
echo $last_main_order_id = $items_collect_order['0']['increment_id'];
Please note that there is a more simpler answer to silvo's:
$orders = Mage::getModel('sales/order')->getCollection();
echo $orders->getLastItem()->getIncrementId();
精彩评论