Skip to main content
Tweeted twitter.com/#!/StackMagento/status/496415954528919552
added 174 characters in body
Source Link
user1704524
  • 2.5k
  • 13
  • 60
  • 106

I've managed to create an Observer to automatically create a shipment when an invoice is created.

The problem I have is with the final part of the code to send the email once the shipment has been created.

I wanted to ask if anyone can notice what is wrong with the $sendEmail call in my code.

Here's my Observer code for _saveShipment()

        protected function _saveShipment(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order, $customerEmailComments = '')
        {
            $shipment->getOrder()->setIsInProcess(true);
            Mage::log($shipment->debug(),Zend_Log::INFO,'shipment.log',true);
            $transactionSave = Mage::getModel('core/resource_transaction')
                ->addObject($shipment)
                ->addObject($order)
                ->save();

            $emailSentStatus = $shipment->getData('email_sent');
            if($emailSentStatus)
                Mage::log("Email has been sent",Zend_Log::INFO,'email.log',true);
            else
                Mage::log("IS FALSE",Zend_Log::INFO,'email.log',true);
//                Mage::log($customerEmailComments,Zend_Log::INFO,'email.log',true);
            if (!is_null($customerEmail) && !$emailSentStatus) {
                $shipment->sendEmail>setEmailSent(true, $customerEmailComments);
                $shipment->setEmailSent>sendEmail(true, $customerEmailComments);
            }

            return $this;
        }

Thanks for you time...

I've managed to create an Observer to automatically create a shipment when an invoice is created.

The problem I have is with the final part of the code to send the email once the shipment has been created.

I wanted to ask if anyone can notice what is wrong with the $sendEmail call in my code.

Here's my Observer code for _saveShipment()

    protected function _saveShipment(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order, $customerEmailComments = '')
    {
        $shipment->getOrder()->setIsInProcess(true);
        Mage::log($shipment->debug(),Zend_Log::INFO,'shipment.log',true);
        $transactionSave = Mage::getModel('core/resource_transaction')
            ->addObject($shipment)
            ->addObject($order)
            ->save();

        $emailSentStatus = $shipment->getData('email_sent');
        if($emailSentStatus)
            Mage::log("Email has been sent",Zend_Log::INFO,'email.log',true);
        else
            Mage::log("IS FALSE",Zend_Log::INFO,'email.log',true);
        if (!is_null($customerEmail) && !$emailSentStatus) {
            $shipment->sendEmail(true, $customerEmailComments);
            $shipment->setEmailSent(true);
        }

        return $this;
    }

Thanks for you time...

I've managed to create an Observer to automatically create a shipment when an invoice is created.

The problem I have is with the final part of the code to send the email once the shipment has been created.

I wanted to ask if anyone can notice what is wrong with the $sendEmail call in my code.

Here's my Observer code for _saveShipment()

        protected function _saveShipment(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order, $customerEmailComments = '')
        {
            $shipment->getOrder()->setIsInProcess(true);
            Mage::log($shipment->debug(),Zend_Log::INFO,'shipment.log',true);
            $transactionSave = Mage::getModel('core/resource_transaction')
                ->addObject($shipment)
                ->addObject($order)
                ->save();

            $emailSentStatus = $shipment->getData('email_sent');
            if($emailSentStatus)
                Mage::log("Email has been sent",Zend_Log::INFO,'email.log',true);
            else
                Mage::log("IS FALSE",Zend_Log::INFO,'email.log',true);
//                Mage::log($customerEmailComments,Zend_Log::INFO,'email.log',true);
            if (!is_null($customerEmail) && !$emailSentStatus) {
                $shipment->setEmailSent(true);
                $shipment->sendEmail(true, $customerEmailComments);
            }

            return $this;
        }

Thanks for you time...

added 27 characters in body
Source Link
user1704524
  • 2.5k
  • 13
  • 60
  • 106

I've managed to create an Observer to automatically create a shipment when an invoice is created.

The problem I have is with the final part of the code to send the email once the shipment has been created.

I wanted to ask if anyone can notice what is wrong with the $sendEmail call in my code.

Here's my Observer code for _saveShipment()

    protected function _saveShipment(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order, $customerEmailComments = '')
    {
        $shipment->getOrder()->setIsInProcess(true);
        Mage::log($shipment->debug(),Zend_Log::INFO,'shipment.log',true);
        $transactionSave = Mage::getModel('core/resource_transaction')
            ->addObject($shipment)
            ->addObject($order)
            ->save();
 

        $emailSentStatus = $shipment->getData('email_sent');
        if($emailSentStatus)
            Mage::log("Email has been sent",Zend_Log::INFO,'email.log',true);
        else
            Mage::log("IS FALSE",Zend_Log::INFO,'email.log',true);
    Mage::log($customerEmailComments,Zend_Log::INFO,'email.log',true);
    if (!is_null($customerEmail) && !$emailSentStatus) {
            $shipment->sendEmail(true, $customerEmailComments);
            $shipment->setEmailSent(true);
        }

        return true;$this;
    }

Thanks for you time...

I've managed to create an Observer to automatically create a shipment when an invoice is created.

The problem I have is with the final part of the code to send the email once the shipment has been created.

I wanted to ask if anyone can notice what is wrong with the $sendEmail call in my code.

Here's my Observer code for _saveShipment()

protected function _saveShipment(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order, $customerEmailComments = '')
{
    $shipment->getOrder()->setIsInProcess(true);
    Mage::log($shipment->debug(),Zend_Log::INFO,'shipment.log',true);
    $transactionSave = Mage::getModel('core/resource_transaction')
        ->addObject($shipment)
        ->addObject($order)
        ->save();
 

    $emailSentStatus = $shipment->getData('email_sent');
    if($emailSentStatus)
        Mage::log("Email has been sent",Zend_Log::INFO,'email.log',true);
    else
        Mage::log("IS FALSE",Zend_Log::INFO,'email.log',true);
    Mage::log($customerEmailComments,Zend_Log::INFO,'email.log',true);
    if (!is_null($customerEmail) && !$emailSentStatus) {
        $shipment->sendEmail();
        $shipment->setEmailSent(true);
    }

    return true;
}

Thanks for you time...

I've managed to create an Observer to automatically create a shipment when an invoice is created.

The problem I have is with the final part of the code to send the email once the shipment has been created.

I wanted to ask if anyone can notice what is wrong with the $sendEmail call in my code.

Here's my Observer code for _saveShipment()

    protected function _saveShipment(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order, $customerEmailComments = '')
    {
        $shipment->getOrder()->setIsInProcess(true);
        Mage::log($shipment->debug(),Zend_Log::INFO,'shipment.log',true);
        $transactionSave = Mage::getModel('core/resource_transaction')
            ->addObject($shipment)
            ->addObject($order)
            ->save();

        $emailSentStatus = $shipment->getData('email_sent');
        if($emailSentStatus)
            Mage::log("Email has been sent",Zend_Log::INFO,'email.log',true);
        else
            Mage::log("IS FALSE",Zend_Log::INFO,'email.log',true);
        if (!is_null($customerEmail) && !$emailSentStatus) {
            $shipment->sendEmail(true, $customerEmailComments);
            $shipment->setEmailSent(true);
        }

        return $this;
    }

Thanks for you time...

Source Link
user1704524
  • 2.5k
  • 13
  • 60
  • 106

Send shipping email using an Observer

I've managed to create an Observer to automatically create a shipment when an invoice is created.

The problem I have is with the final part of the code to send the email once the shipment has been created.

I wanted to ask if anyone can notice what is wrong with the $sendEmail call in my code.

Here's my Observer code for _saveShipment()

protected function _saveShipment(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order, $customerEmailComments = '')
{
    $shipment->getOrder()->setIsInProcess(true);
    Mage::log($shipment->debug(),Zend_Log::INFO,'shipment.log',true);
    $transactionSave = Mage::getModel('core/resource_transaction')
        ->addObject($shipment)
        ->addObject($order)
        ->save();


    $emailSentStatus = $shipment->getData('email_sent');
    if($emailSentStatus)
        Mage::log("Email has been sent",Zend_Log::INFO,'email.log',true);
    else
        Mage::log("IS FALSE",Zend_Log::INFO,'email.log',true);
    Mage::log($customerEmailComments,Zend_Log::INFO,'email.log',true);
    if (!is_null($customerEmail) && !$emailSentStatus) {
        $shipment->sendEmail();
        $shipment->setEmailSent(true);
    }

    return true;
}

Thanks for you time...