Simon Janssen
Simon Janssen

Reputation: 187

Get order id in Magento from order data in Wyomind Order Export tool module

How can i get the order_id (entity or increment id) in Magento backend dynamically? I have found a lot of examples where the order id is supplied as a static value. See Getting Order Number from Order Id in Magento? for example.

I want to supply the order_id from a current scope, so the current order id of the order. Maybe this should be referenced with the help of "$this". This is a example i came across:

$orderId = 64;
$order   = Mage::getModel('sales/order')->load($orderId);

echo $order->getIncrementId();    

I would like the info in a back-end module, not on the succes page or in front-end.

Upvotes: 0

Views: 488

Answers (3)

Simon Janssen
Simon Janssen

Reputation: 187

Another shorthand is to use the following code directly in the pattern in the template:

<? return str_replace(".","","{base_price_incl_tax product}"); ?>

In this way you don't have to create a custom attribute.

Upvotes: 1

Simon Janssen
Simon Janssen

Reputation: 187

It works now by using the following code:

$orderId = $item->getId();
$orderIncrementId = $item->getIncrementId();

To retrieve the housenumber or street i used:

$orderId = $item->getId();
$order = Mage::getModel('sales/order')->load($orderId);
// For getting Customer Order Info
$billing_housenumber = $order->getBillingAddress()->getStreet(2);
return $billing_housenumber;
$billing_street = $order->getBillingAddress()->getStreet(1);
return $billing_street;

You have to use the return value to "print" the value in the CVS/XML.

Upvotes: 0

SH-
SH-

Reputation: 1642

As per the comments you are using Wyomind's Order Export tool and you are trying to retrieve the order_id or the increment_id with the custom PHP code option the module offers. (STEP 4: Create your custom attributes).

To do this you can use the $item variable. As per their documentation the $item variable contains the current order.

So:

$orderId = $item->getId();
$orderIncrementId = $item->getIncrementId();

Will get you the two values your question asks about.


Note: You may be better served using built in methods.

{firstname shipping} {lastname shipping} 
{postcode shipping} {street shipping,[implode]}
{city shipping} {country_id shipping}

Where {street shipping,[implode]} looks on point. (Based on your comments).

Upvotes: 1

Related Questions