How to get the next order id of orders in Magento

Pradino

I have been using below code to get the next order id in Magento

     $getNewOrderId = Mage::getSingleton('eav/config')->getEntityType('order')->fetchNewIncrementId($storeId);

This works fine but the problem for this code is it changes the increment_last_id field in table eav_entity_store to this new order id.

So, if your order was not processed, the order id has already incremented and hence the order id would get lost, as next time before creating orders Magento will increment this value in the table and process the order.

How can we get the next order id without incrementing the value in the table, it obviously will change the value in this table when the order is created in the latter part of the code.

I am using this piece of code to create orders programmatically

Marius

Try this:

$entityStoreConfig = Mage::getModel('eav/entity_store')->loadByEntityStore($this->getId(), $storeId);

$incrementInstance = Mage::getModel($this->getIncrementModel())
            ->setPrefix($entityStoreConfig->getIncrementPrefix())
            ->setPadLength($this->getIncrementPadLength())
            ->setPadChar($this->getIncrementPadChar())
            ->setLastId($entityStoreConfig->getIncrementLastId())
            ->setEntityTypeId($entityStoreConfig->getEntityTypeId())
            ->setStoreId($entityStoreConfig->getStoreId());

$nextId = $incrementInstance->getNextId();

The code is taken from the fetchNewIncrementId method. I just omitted the save part.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get Shipment Increment ID by Order ID in Magento

From Dev

Magento: How to get customer group ID from sales/order_item collection?

From Dev

How to get order increment id using order id?

From Dev

How to get Magento Order data from Observer

From Dev

How to get number of items that has been shipped in a Magento order?

From Dev

Magento how to get attribute value by option id?

From Dev

How to get all order details including payment custmer and shipping details from order id Magento

From Dev

How to get website id using Order Object in Magento

From Dev

how to get id of next element jquery?

From Dev

get order details by Order Id in magento

From Dev

Missing orders in Magento 1.8 but are showing paid in Braintree with order number

From Dev

Get Magento Order ID, Order Value and Coupon Code in success.phtml

From Dev

How to get Item Custom options after order success in magento?

From Dev

How to get all orders over period by a collection in Magento?

From Dev

how to get order collection object in magento 2

From Dev

Magento - How to get all orders except the ones with specific status

From Dev

How to get all order payment method information in magento2

From Dev

How to get back order status of a product in Magento CE 1.7?

From Dev

How to get completion date of an order in Magento

From Dev

How to get the order id from $observer in magento

From Dev

How to get Shipment Increment ID by Order ID in Magento

From Dev

How to get order increment id using order id?

From Dev

How to increase order id from particular number in magento

From Dev

Magento how to get attribute value by option id?

From Dev

How to get all order details including payment custmer and shipping details from order id Magento

From Dev

Missing orders in Magento 1.8 but are showing paid in Braintree with order number

From Dev

Get Magento installation id?

From Dev

How to get all orders over period by a collection in Magento?

From Dev

How to get all order payment method information in magento2

Related Related

  1. 1

    How to get Shipment Increment ID by Order ID in Magento

  2. 2

    Magento: How to get customer group ID from sales/order_item collection?

  3. 3

    How to get order increment id using order id?

  4. 4

    How to get Magento Order data from Observer

  5. 5

    How to get number of items that has been shipped in a Magento order?

  6. 6

    Magento how to get attribute value by option id?

  7. 7

    How to get all order details including payment custmer and shipping details from order id Magento

  8. 8

    How to get website id using Order Object in Magento

  9. 9

    how to get id of next element jquery?

  10. 10

    get order details by Order Id in magento

  11. 11

    Missing orders in Magento 1.8 but are showing paid in Braintree with order number

  12. 12

    Get Magento Order ID, Order Value and Coupon Code in success.phtml

  13. 13

    How to get Item Custom options after order success in magento?

  14. 14

    How to get all orders over period by a collection in Magento?

  15. 15

    how to get order collection object in magento 2

  16. 16

    Magento - How to get all orders except the ones with specific status

  17. 17

    How to get all order payment method information in magento2

  18. 18

    How to get back order status of a product in Magento CE 1.7?

  19. 19

    How to get completion date of an order in Magento

  20. 20

    How to get the order id from $observer in magento

  21. 21

    How to get Shipment Increment ID by Order ID in Magento

  22. 22

    How to get order increment id using order id?

  23. 23

    How to increase order id from particular number in magento

  24. 24

    Magento how to get attribute value by option id?

  25. 25

    How to get all order details including payment custmer and shipping details from order id Magento

  26. 26

    Missing orders in Magento 1.8 but are showing paid in Braintree with order number

  27. 27

    Get Magento installation id?

  28. 28

    How to get all orders over period by a collection in Magento?

  29. 29

    How to get all order payment method information in magento2

HotTag

Archive