How to get last running transaction Id in magento

北慕城南 提交于 2020-01-14 13:11:13

问题


How can I get the last running transaction Id ? (eg: 10000001) I've tried numerous ways, with no success.


回答1:


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




回答2:


Try this:

$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();



回答3:


$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'];



回答4:


Please note that there is a more simpler answer to silvo's:

$orders = Mage::getModel('sales/order')->getCollection();
echo $orders->getLastItem()->getIncrementId();


来源:https://stackoverflow.com/questions/3698395/how-to-get-last-running-transaction-id-in-magento

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!