I'm a mid-level developer to Magento, and I would like to know the re-ordering algorithm since I was tasked to modify the re-ordering logic in a Magento store.
Currently, when an admin user re-orders a previous order, then the increment id (let's say (100166118) becomes 100166118-1 (note -1 suffix) after the re-order is done.
My question is this:
Does the logic that suffixing the order's order_increment_id (by -1 or -2 and so on) is something that native Magento code does, or is it something that a 3rd plugin does? Or is it a custom developer's code?
Your reply would be greatly appreciated
The logic of suffixing the order increment ID with a "-1" or "-2" is part of the native Magento code. When a reorder is created, Magento creates a new order with a new increment ID that is based on the original order. The new increment ID is generated by appending a suffix "-1", "-2", etc. to the original order's increment ID. This is done to ensure that the new order has a unique increment ID and does not overwrite the original order.
The code responsible for generating the new increment ID can be found in the Mage_Sales_Model_Service_Quote class, in the submitReorder method. Here's a code snippet that shows how the new increment ID is generated:
bash
Copy code
$incrementId = $this->_getOrder()->getIncrementId();
$incrementIdParts = explode('-', $incrementId);
if (count($incrementIdParts) == 1) {
$incrementIdParts[] = 1;
} else {
$incrementIdParts[1]++;
}
$incrementId = implode('-', $incrementIdParts);
As you can see, the code checks if the original increment ID already has a suffix. If it does, it increments the suffix. If it doesn't, it adds a suffix of "-1".
Regards,
Rachel Gomez