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 2
Print order
 
patrecord
Guru
 
Avatar
Total Posts:  461
Joined:  2008-06-01
 

please in order details inser one button to print an order.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bojan Hrnkas
Member
 
Total Posts:  51
Joined:  2008-04-15
 

Are there any modules in the meantime that can do this?
I’d like to offer my customers possibility to print an order from the cart.

Greets!

Bojan Hrnkas

 
Magento Community Magento Community
Magento Community
Magento Community
 
youngilaboungi
Jr. Member
 
Avatar
Total Posts:  28
Joined:  2008-11-27
Alexandria, Egypt
 

This one doesnt have a mass print option, i guess coz they have to override the OrderController.
can some one give the code to enable mass printing of orders through the sales orders list page and/or the invoices list page?

 
Magento Community Magento Community
Magento Community
Magento Community
 
zamb
Member
 
Total Posts:  44
Joined:  2009-07-10
 

if you need the mass printing option..buy foomans extension (order manager)

 
Magento Community Magento Community
Magento Community
Magento Community
 
youngilaboungi
Jr. Member
 
Avatar
Total Posts:  28
Joined:  2008-11-27
Alexandria, Egypt
 

no, fooman’s is not what I’m lookin for. anyway I solved it already,

OK, so first we need to put a “Print Orders” in the action drop down menu on the sales orders page. 
This is done by overriding the sales order grid by
copying /app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
to /app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php

then edit it by adding this to the suitable place in the code:

$this->getMassactionBlock()->addItem('pdforders_order', array(
             
'label'=> Mage::helper('sales')->__('Print Orders'),
             
'url'  => $this->getUrl('*/*/pdforders'),
        ));

Now, we need to write the pdfordersAction() function that will be executed from the sales order page by editing the controller file.
Well, I got the code right, but the thing someone might dislike is that I edited the core controller file which is not professional.  Please someone help out how to cleanly overload the function withought touching the core files to be upgrading proof.

I edited: /app/code/core/Adminhtml/controllers/Sales/OrderController.php adding:

public function pdfordersAction(){
        $orderIds 
$this->getRequest()->getPost('order_ids');
        
$flag false;
        if (!empty(
$orderIds)) {
            
foreach ($orderIds as $orderId{
                $order 
Mage::getModel('sales/order')->load($orderId);
                
$flag true;
                
$order->setOrder($order);
                if (!isset(
$pdf)){
                $pdf 
Mage::getModel('Nastnet_OrderPrint/order_pdf_order')->getPdf(array($order));
                
else {
                $pages 
Mage::getModel('Nastnet_OrderPrint/order_pdf_order')->getPdf(array($order));
                
$pdf->pages array_merge ($pdf->pages$pages->pages);
                
}
            }
            
if ($flag{
                
return $this->_prepareDownloadResponse('order'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf'$pdf->render(), 'application/pdf');
            
else {
                $this
->_getSession()->addError($this->__('There are no printable documents related to selected orders'));
                
$this->_redirect('*/*/');
            
}

        }
        $this
->_redirect('*/*/');

    
}

well, I hope this helps someone out.  I thank Nastnet so much for his work, saved me lots of trouble.  Still I dont have the time to properly test overloading the function in a clean way, so I’m waiting for someone else’s contribution.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Patrix
Jr. Member
 
Total Posts:  28
Joined:  2009-11-27
 

Hey youngilaboungi,
I tried your code and it worked like a charm!
absolutely great! thank you!!!!

I will try to contribute with the override, hoping to find a solution.

 
Magento Community Magento Community
Magento Community
Magento Community
 
GreenSkunk
Jr. Member
 
Avatar
Total Posts:  6
Joined:  2008-04-09
New York
 

Check the Wiki page http://www.magentocommerce.com/wiki/how_to_overload_a_controller

 
Magento Community Magento Community
Magento Community
Magento Community
 
Spranks
Sr. Member
 
Avatar
Total Posts:  99
Joined:  2009-08-12
Frankfurt am Main
 

Thanks a lot for your nice function! This was really helpful for my custom solution.

The module Nastnet OrderPrint already overloads the OrderController. So you just have to copy your function to the overloaded OrderController which you find under app/code/local/Nastnet/OrderPrint/controllers/OrderController.php or something…

Cheers,
Simon

 
Magento Community Magento Community
Magento Community
Magento Community
 
jazkat
Sr. Member
 
Total Posts:  154
Joined:  2009-07-09
 

Thanks to youngilaboungi for the code and Simon S. for the tip on including into Nastnet!!

Works great in Mage v1.3.2.4.

Edited:

I noticed (I forgot) that I have installed Asperience Printorderline extension and as it has the same function name for creating PDF as this code from youngilaboungi for Nastnet.

If you’re using Nastnet you (might) also need to change file:
\app\code\local\Nastnet\OrderPrint\etc\config.xml
where <rewrite> is defined under <global>:
add before end tag </rewrite>

<Nastnet_OrderPrint_OrderController>
    <
from><![CDATA[#/\w+/sales_order/pdforders/#]]></from>
    
<to>/orderprint/order/pdforders/</to>
 </
Nastnet_OrderPrint_OrderController>

If you don’t have Nastnet extension installed then you (most likely) don’t need to change config file.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nwd37210
Jr. Member
 
Total Posts:  17
Joined:  2009-12-28
 

I’m getting an error when I choose “print orders” from the dropdown.

Here it is:

Warning: include(Mage/Nastnet/OrderPrint/Model/Order/Pdf/Order.php) [function.include]: failed to open stream: No such file or directory in /home/hinkle1/webapps/dw/lib/Varien/Autoload.php on line 93
Trace:
#0 /home/hinkle1/webapps/dw/lib/Varien/Autoload.php(93): mageCoreErrorHandler(2, ‘include(Mage/Na...’, ‘/home/hinkle1/w...’, 93, Array)
#1 /home/hinkle1/webapps/dw/lib/Varien/Autoload.php(93): Varien_Autoload::autoload()
#2 [internal function]: Varien_Autoload->autoload(’Mage_Nastnet_Or...’)
#3 [internal function]: spl_autoload_call(’Mage_Nastnet_Or...’)
#4 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Model/Config.php(1084): class_exists(’Mage_Nastnet_Or...’)
#5 /home/hinkle1/webapps/dw/app/Mage.php(319): Mage_Core_Model_Config->getModelInstance(’Nastnet_OrderPr...’, Array)
#6 /home/hinkle1/webapps/dw/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(368): Mage::getModel(’Nastnet_OrderPr...’)
#7 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Controller/Varien/Action.php(376): Mage_Adminhtml_Sales_OrderController->pdfordersAction()
#8 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(’pdforders’)
#9 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#10 /home/hinkle1/webapps/dw/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#11 /home/hinkle1/webapps/dw/index.php(65): Mage::run()
#12 {main}

Image Attachments
Screen shot 2010-03-04 at 7.49.32 PM.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
nwd37210
Jr. Member
 
Total Posts:  17
Joined:  2009-12-28
 

I’m getting an error when I choose “print orders” from the dropdown.

Here it is:

Warning: include(Mage/Nastnet/OrderPrint/Model/Order/Pdf/Order.php) [function.include]: failed to open stream: No such file or directory in /home/hinkle1/webapps/dw/lib/Varien/Autoload.php on line 93
Trace:
#0 /home/hinkle1/webapps/dw/lib/Varien/Autoload.php(93): mageCoreErrorHandler(2, ‘include(Mage/Na...’, ‘/home/hinkle1/w...’, 93, Array)
#1 /home/hinkle1/webapps/dw/lib/Varien/Autoload.php(93): Varien_Autoload::autoload()
#2 [internal function]: Varien_Autoload->autoload(’Mage_Nastnet_Or...’)
#3 [internal function]: spl_autoload_call(’Mage_Nastnet_Or...’)
#4 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Model/Config.php(1084): class_exists(’Mage_Nastnet_Or...’)
#5 /home/hinkle1/webapps/dw/app/Mage.php(319): Mage_Core_Model_Config->getModelInstance(’Nastnet_OrderPr...’, Array)
#6 /home/hinkle1/webapps/dw/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(368): Mage::getModel(’Nastnet_OrderPr...’)
#7 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Controller/Varien/Action.php(376): Mage_Adminhtml_Sales_OrderController->pdfordersAction()
#8 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(’pdforders’)
#9 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#10 /home/hinkle1/webapps/dw/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#11 /home/hinkle1/webapps/dw/index.php(65): Mage::run()
#12 {main}

Image Attachments
Screen shot 2010-03-04 at 7.49.32 PM.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
nwd37210
Jr. Member
 
Total Posts:  17
Joined:  2009-12-28
 

I’m getting an error when I choose “print orders” from the dropdown.

Here it is:

Warning: include(Mage/Nastnet/OrderPrint/Model/Order/Pdf/Order.php) [function.include]: failed to open stream: No such file or directory in /home/hinkle1/webapps/dw/lib/Varien/Autoload.php on line 93
Trace:
#0 /home/hinkle1/webapps/dw/lib/Varien/Autoload.php(93): mageCoreErrorHandler(2, ‘include(Mage/Na...’, ‘/home/hinkle1/w...’, 93, Array)
#1 /home/hinkle1/webapps/dw/lib/Varien/Autoload.php(93): Varien_Autoload::autoload()
#2 [internal function]: Varien_Autoload->autoload(’Mage_Nastnet_Or...’)
#3 [internal function]: spl_autoload_call(’Mage_Nastnet_Or...’)
#4 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Model/Config.php(1084): class_exists(’Mage_Nastnet_Or...’)
#5 /home/hinkle1/webapps/dw/app/Mage.php(319): Mage_Core_Model_Config->getModelInstance(’Nastnet_OrderPr...’, Array)
#6 /home/hinkle1/webapps/dw/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(368): Mage::getModel(’Nastnet_OrderPr...’)
#7 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Controller/Varien/Action.php(376): Mage_Adminhtml_Sales_OrderController->pdfordersAction()
#8 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(’pdforders’)
#9 /home/hinkle1/webapps/dw/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#10 /home/hinkle1/webapps/dw/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#11 /home/hinkle1/webapps/dw/index.php(65): Mage::run()
#12 {main}

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mike
Member
 
Total Posts:  43
Joined:  2007-09-11
Los Angeles, CA
 

Hello. Thank you (all) for the great documentation on a much-needed element for Magento.

I have the following problem…

While it DOES work for creating a PDF for an order with a \"simple\" product in the order, I get the following error on any other order (in which there are \"grouped\" products:

Fatal error: Class \'Nastnet_OrderPrint_Model_Order_Pdf_Items_Invoice_Default\' not found in /home/MYDOMAIN/public_html/app/code/local/Nastnet/OrderPrint/Model/Order/Pdf/Items/Order/Grouped.php  on line 22

Note: I have…

- Installed the admin-order-printing-extension
- Copied & Modified \"Grid.php\" into /app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php
- Modified \"OrderController.php\" at /app/code/core/Adminhtml/controllers/Sales/OrderController.php
- Modified \"config.xml\" at /app/code/local/Nastnet/OrderPrint/etc/config.xml

(all following the instructions listed above)

Is there something I\’m missing?

Thanks in advance for any & all help!

 
Magento Community Magento Community
Magento Community
Magento Community
 
kornbread
Jr. Member
 
Total Posts:  25
Joined:  2008-10-03
 
Simon S. - 08 February 2010 08:06 AM

Thanks a lot for your nice function! This was really helpful for my custom solution.

The module Nastnet OrderPrint already overloads the OrderController. So you just have to copy your function to the overloaded OrderController which you find under app/code/local/Nastnet/OrderPrint/controllers/OrderController.php or something…

Cheers,
Simon

I get a 404 page not found error if I try this.  I’m assuming it has to do with the code:

$this->getMassactionBlock()->addItem('pdforders_order', array(
             
'label'=> Mage::helper('sales')->__('Print Orders'),
             
'url'  => $this->getUrl('*/*/pdforders'),
        ));

Specifically the line:

'url'  => $this->getUrl('*/*/pdforders'),

However, I’m not sure what it should be.  Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Spranks
Sr. Member
 
Avatar
Total Posts:  99
Joined:  2009-08-12
Frankfurt am Main
 

Post the code of your app/code/local/Nastnet/Packingslip/Block/Grid.php and of your app/code/local/Nastnet/Packingslip/controllers/OrderController.php

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiaraweb
Guru
 
Avatar
Total Posts:  721
Joined:  2008-03-21
Aviano ~ Italy
 
kornbread - 06 April 2010 05:47 PM

I get a 404 page not found error if I try this.  I’m assuming it has to do with the code:

$this->getMassactionBlock()->addItem('pdforders_order', array(
             
'label'=> Mage::helper('sales')->__('Print Orders'),
             
'url'  => $this->getUrl('*/*/pdforders'),
        ));

Specifically the line:
'url'  => $this->getUrl('*/*/pdforders'),

However, I’m not sure what it should be.  Any ideas?

I have the same trouble
404 NOT FOUND

I applied all modifications described here, and I have Nastnet installed

It seems that the redirect is not right

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