I know that, Magento has it's own way of generating order ids for orders placed through it.

Instead of the default way, I want to set product sku as the prefix for order-ids and keep order increment id as it is.

Is there any way to achieve this in Magento?

  • 1
    What should happen if your customer purchase more than one product? – zhartaunik Jul 6 '15 at 7:42
  • we are allowing only one product..user can't buy more than one product at a time – Overseas634 Jul 6 '15 at 7:56

No, the order ID is an integer value. Example:

  • order_id = 1
  • increment_id = "1000000001"

It might be possible the other way around, though. You can create your own increment model for orders to define arbitrary logic for the increment id.

You will need to implement Mage_Eav_Model_Entity_Increment_Interface with the method getNextId().

It is not intended to access the actual order data at this point, but since it is called during order creation, you should be able to call Mage::registry('current_order') and look through the order items and their SKU.

Further reading: Magento Tutorial: How to Use Increment Models to Generate IDs (or SKUs)

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.