1

I need to customize some parts on the most "important" templates, like new order, status update etc, and I wanna put a link that takes the buyer directly to the order view page, which structure is:

http://mystore.com/sales/order/view/order_id/13/

So, my doubt is about how to get the real order id that ends the url, and the point is: when we use the variable {{var order.increment_id}}, system gets something like 100000013, and I need only "13", as we can see at the url above.

Is it possible to get only the real order id, without that "1000000..." ?

1 Answer 1

2

The first thing to understand here is that the increment id will not always match the entity ID (with a prefix), so don't try to strip the prefix off, you'll end in all kinds of mess.

It's been awhile since I've looked at this stuff, but I believe order in this case is an instance of Mage_Sales_Model_Order, so you should just be able to use {{var order.getId() }}. This should return the entity_id field from the database as opposed to the increment_id.

4
  • Got it, thanks! I've seen this in a lot of big ecommerces in Brazil, they put in every email message a button such as "Click here to print your invoice" or "Click to pay now" and for those actions we need the order id, as expected. Is there some page in Magento docs where I can take for reference all available variables to use in email templates? Commented Jan 2, 2015 at 17:17
  • I'm not aware of a page, but you should be able to use almost any function on Mage_Sales_Model_Order. Commented Jan 2, 2015 at 17:19
  • Great, I will take a look at the model to see all options. Commented Jan 2, 2015 at 17:34
  • Your tip worked! I could get the order id using {{var order.getId() }}. Do you guess all variables from Mage_Sales_Model_Order could be used into the new order email template? Commented Jan 6, 2015 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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