2

We are integrating Magento with an existing system. Our existing system already has order numbers. There has been a lot of confusion since Magento has its own order numbers, and our existing system has different order numbers, so we're trying to get the order numbers to match up.

I have an observer set up for sales_order_place_after where I get the order number from our existing system. It doesn't seem to work to $order->setIncrementId($our_existing_order_id) I don't know if this is really all that good of an idea anyways..

Really, the end goal we want is for the order #s in email receipts that are sent out to match the order #s in our existing systems. Is there a better way to make that happen?

  • Are you just trying to change order increment id to match your system only once or do you need to get an order id from your existing system everytime (will your existing system continue to place orders along side magento)? – Renon Stewart Oct 28 '14 at 16:32
  • What is the format of the order numbers in the external system? – Jonathan Hussey Oct 28 '14 at 16:53
  • As long as you can handle the fact that Magento will preallocate order numbers during card submission and therefore will skip numbers on card decline. Magento will need the driver's seat on creating the SO number which then gets delivered to the ERP system. – Fiasco Labs Oct 28 '14 at 17:32
  • 2
    What I would recommend is to create a new field in sales_flat_order to store this id then update the different template as needed to display this number. This way you will have a clean upgrade path in the future – Renon Stewart Oct 28 '14 at 18:15
  • 1
    Rarely is there an easy solution when Magento and ERP integration are mentioned in the same paragraph. Anything that has id_ in Magento pretty much needs to be left alone as it's a table key and having a field to hold the ERP generated SO number is the best way of handling it. Then show it in the grid on the backend and search/sort on it. – Fiasco Labs Oct 28 '14 at 19:03
1

What I would recommend is to create a new field in sales_flat_order to store this id then update the different template as needed to display this number. This way you will have a clean upgrade path in the future

4

One solution would be to create your own eav entity model. If you look in the eav_entity_type table in the column increment_model you see there is a class path there. Replace those with your own custom model, for example [module]/entity_increment_erp

class [Namespace]_[Model]_Model_Entity_Increment_Erp extends Mage_Eav_Model_Entity_Increment_Abstract
{
    public function getNextId()
    {
        /**
        * your custom code to generate the increment ID, 
        * as long as it is unique
        */

        return $id;
    }
}
  • 1
    I think @R.S suggestion will be good for him, rather than changing the way how Magento works it's better to connect his ERP order number with a custom field in order table. – Kalpesh Nov 7 '14 at 21:54
  • Good point, hopefully he adds his comment as answer too :) – Sander Mangel Nov 7 '14 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.