1

I'm tiring to create shipment for orders using php external script on magento version 1.9.3.4

But shipment is not create in order and not sending the email, it didn't throw any error info at all. i tried change by codes but nothing happens.

The order item loop also working fine. can someone know about the issue of these code or is there need to do some other codes to create shipment

Thank You

     require_once('../app/Mage.php');
        umask(0);
        Mage::setIsDeveloperMode(true);
        Mage::app(0);


            $comment = 'Hello test';
            $email = true;
            $includeComment = true;                                                    
            $order = Mage::getModel('sales/order')->loadByIncrementId('100000052');


            $convertor = Mage::getModel('sales/convert_order');
            $shipment = $convertor->toShipment($order);


            foreach ($order->getAllItems() as $orderItem)
            {

                $item = $convertor->itemToShipmentItem($orderItem);
                $shipment->addItem($item);
//test name show product name which indicate order items retrieve fine
                echo $orderItem->getName();

            }

            Mage::register('current_shipment', $shipment);

            $shipment->register();
            $shipment->addComment($comment,true);
            $shipment->setEmailSent(true);
            $shipment->getOrder()->setIsInProcess(true);

            $transactionSave = Mage::getModel('core/resource_transaction')
                ->addObject($shipment)
                ->addObject($shipment->getOrder())
                ->save();

            $shipment->sendEmail(true);
echo 'this also showing which means script runs without fetal errors';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.