Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 10
[SOLVED] Export orders
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

hey guys,

I think I did it!!

some FEATURES:
unlimited xml samples
export orders from last export
export selected orders (in the admin/sales/order) => easy to filter the orders (by name, date range etc..) to export
etc, etc…

STEP1:
app/design/adminhtml/default/default/template/widget/grid/massaction.phtml

between the first two line insert:

<?php include('export.php'); ?>

so now u’ve got:

<div id="<?php echo $this->getHtmlId() ?>">
<?php include('export.php'); ?>
<table cellspacing="0" cellpadding="0" class="massaction">

STEP2:
copy the enclosed ‘samples.php’, ‘includes.php’, ‘export.php’ files to
app/design/adminhtml/default/default/template/widget/grid/

STEP3:
create a folder called ‘export’ in the root folder (of the server)

STEP4:
app/code/core/Mage/Core/functions.php
find (around: row 245):

throw new Exception($errorMessage);
and comment it out, otherwise u will get an error (I do not know why)

go to admin of your store, sales/orders and there is the magic… smile

(make a htaccess protection on the export folder...)
About customizing the xml files:
xml sample formats can be found in the samples.php
you can customize as u wish…

in my original file you can find 4 different samples (Default,Advanced,Simple,Custom)… add/remove/rename them as wanted

the text before the ‘:’ means the tagname that will shown in the xml.. you can modified as u wish
after the ‘:’ the text refer to the value (the value is located in the includes.php… function getValue...)

in my example there are only a few value from the orders, if you need more (e.g paymentmethod) then just addid yourself:
step 1:
in the getValue function add a new case like this:

case "getpaymentmethodexample":
        return 
$orderMag->getPayment()->getMethod();

step 2:
now in the samples.php now you can reach the value:

.
.
.
    
shippingamountgetshippingamount,
    
writehereyourtagnamegetpaymentmethodexample,
    
grandtotalgetgrandtotal
.
.
.

ENJOY!
Szotyi

File Attachments
samples.php  (File Size: 3KB - Downloads: 1474)
includes.php  (File Size: 10KB - Downloads: 1283)
export.php  (File Size: 6KB - Downloads: 1699)
 
Magento Community Magento Community
Magento Community
Magento Community
 
titi88888888
Jr. Member
 
Total Posts:  2
Joined:  2008-10-02
 

Oh my friend ! This is Very good Stuffs !

Thank you very much !

I’m gonna try it Right Away !

Thanks !

 
Magento Community Magento Community
Magento Community
Magento Community
 
titi88888888
Jr. Member
 
Total Posts:  2
Joined:  2008-10-02
 

I have a 404 error because my magento shop is in a subfolder : www.yourdomaine.com/shop

Then, when I click on “Export”, it doesn’t take into account my /shop/ folder

http://www.MyDomain.com/index.php/admin/sales_order/?export=true&type;=custom&sample;=Default&orderlist;=

Instead of http://www.MyDomain.com/shop/index.php/admin/sales_order/?export=true&type;=custom&sample;=Default&orderlist;=

Could you please explain us HOW TO MODIFY the catual scripts for people having their shops in a subfolder ?

Thank you !

 
Magento Community Magento Community
Magento Community
Magento Community
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

it is just a link:
export.php
row 123 and 126
change:
<a href="/shop/index.php/admin/sales_order/....

your welcome and waiting for feedback

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brady
Guru
 
Avatar
Total Posts:  330
Joined:  2007-09-10
Orange County, CA
 

This has some serious potential. Nice job and thank you very much for this contribution!

However, when I export either all orders or selected orders, with the “default” option, I receive the following XML error:

XML Parsing Errornot well-formed
Location
http://localhost/export/ndox.xml
Line Number 1532Column 21:            <shippingname>L  Magement</shippingname>
-----------------------------------------^

UPDATE: Looks like it’s breaking because of the “&” symbol. When I change all references in the XML file to “&”, it works fine. Is there any way to automate that process when it creates the XML?

 
Magento Community Magento Community
Magento Community
Magento Community
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

oh yeah, sorry I was in rush when I wrote it.
insert at the end of the includes.php:
the function from:
http://snipplr.com/view/10262/xml-safe-characters/

in the same file find the ‘getValue($value, $item, $option)’ ïn the arraytransform function and replace to:
xmlSafe(getValue($value, $item, $option))

 
Magento Community Magento Community
Magento Community
Magento Community
 
SapinTremblant
Jr. Member
 
Total Posts:  14
Joined:  2009-01-14
 

@szotyi : your code is a miracle to me, thanks. BTW, where can I found all value names of magento to be able to export more info like phone number, tax, postal code etc…

in your ‘include.php’ file you wrote :

‘ NOTE: it is NOT complete list you can find an extended list in the enclosed file’ => I do not have this file or could not find it.

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

hey,

here is the list.

how it works:
u find in the list what u want to add:
lets say I need for the order items three more information: the quantity how much has invoiced , the product type, and the updated time
i have found in the list:
qty_invoiced, product_type, updated_at
then u go to the includes.php file to getValue()
and add this three line

case "examplegetqtyinvoiced":
        return 
$item->getQtyInvoiced();

    case 
"renameitgetproducttype":
        return 
$item->getProductType();
        
    case 
"somethinggetupdatedat":
        return 
$item->getUpdatedAt();

now for the sample.php u can reach the value:

.
        
updatesomethinggetupdatedat,
        
typerenameitgetproducttype,
        
invoicedexamplegetqtyinvoiced,
.

so how did the getQtyInvoiced come from the qty_invoiced?
just putting the word ‘get’ before the word from the list, Remove the ‘_’ and made it capital the letters as the sample
I am not sure that it works for every properties…

File Attachments
list.txt  (File Size: 3KB - Downloads: 1058)
 
Magento Community Magento Community
Magento Community
Magento Community
 
SapinTremblant
Jr. Member
 
Total Posts:  14
Joined:  2009-01-14
 

Thanks, everything goes fine.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kdouglas
Jr. Member
 
Total Posts:  3
Joined:  2009-01-06
 

Great work and thank you very much, I’ve just spent a few days testing this and have now put in on our production server.

I also made some minor modifications and wrote a php script which generates a pdf file from the xml output, I’ve replaced the xml download link with a link to this pdf generation script.

If anyone is interested in it PM me and I can give you a copy.

(I will post it on-thread in a few days when I get a chance to tidy the code a little)

 
Magento Community Magento Community
Magento Community
Magento Community
 
redhotrobbie
Jr. Member
 
Total Posts:  27
Joined:  2008-10-27
 

When I hit export I get 404 not found error.

shop/index.php/admin/sales_order/?export=true&type;=fromlast&sample;=Default

Does anyone know where the problem is?

 
Magento Community Magento Community
Magento Community
Magento Community
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

what type of browser are u using?

http://buywine.co.il/index.php/admin/sales_order/?export=true&type;=fromlast&sample;=Default

the ‘;’ should not be in the url…

 
Magento Community Magento Community
Magento Community
Magento Community
 
SapinTremblant
Jr. Member
 
Total Posts:  14
Joined:  2009-01-14
 

@szotyi : you script is great as I mentionned, and I would like to custommize it a bit. Is it possible to get all items of a bundle product on a “sub-item” line with it SKU and qty ?

<item>
<sku>bundle product SKU</sku>
<sub-sku>qty-productA</sub-sku>
<sub-sku>qty-productB</sub-sku>
<sub-sku>qty-productC</sub-sku>
<sub-sku>qty-productD</sub-sku>
</item>

If it not possible or to long how can I change the “-” separating items in bundle product to “_”

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
redhotrobbie
Jr. Member
 
Total Posts:  27
Joined:  2008-10-27
 

i was using firefox

on safari get same error w/o the ; in the url!!

shop/index.php/admin/sales_order/?export=true&type;=custom&sample;=Default&orderlist;=

Maybe im missing something ?  I followed 4 steps…

 
Magento Community Magento Community
Magento Community
Magento Community
 
gagachaga
Jr. Member
 
Total Posts:  11
Joined:  2009-02-02
 

HELLO???
great script i have big problem i get
Fatal error: Call to undefined function php�include() in /home6/blah/public_html/shop/app/design/adminhtml/default/default/template/widget/grid/massaction.phtml on line 28

that line is the line that is the include of export.php
i did comment out the line in functions.php
/*throw new Exception($errorMessage); */

yet i still get this error, anyone out there?
i need help ASAP tx very very very much

ps i have tried chmoding, trying require instead of include, and i even tried content include they all give this error, i even tried absolute path of export.php
i guess this is the problem that szotyi mentioned for the commenting

 
Magento Community Magento Community
Magento Community
Magento Community
 
gagachaga
Jr. Member
 
Total Posts:  11
Joined:  2009-02-02
 

i have also tried doing this all over on a new magento install, yet nothing changed :(

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 10