1

My di.xml file is

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
   <preference for="Magento\Sales\Model\Order\Email\Sender\OrderSender" type="ABC\Listrak\Model\Order\Email\Sender\OrderSender" />
</config>

My class

namespace ABC\Listrak\Model\Order\Email\Sender;

class OrderSender extends \Magento\Sales\Model\Order\Email\Sender\OrderSender
{   
    public function __construct(
            \Psr\Log\LoggerInterface $logger
    )
    {
        $this->logger = $logger;
    }

    public function send(Order $order, $forceSyncMode = false)
    {
        $order->setSendEmail(true);

        if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
            if ($this->checkAndSend($order)) {
                $order->setEmailSent(true);
                $this->orderResource->saveAttribute($order, ['send_email', 'email_sent']);
                return true;
            }
        }

        $this->orderResource->saveAttribute($order, 'send_email');

        return false;
    }


}

But i get Error

Warning: Declaration of ABC\Listrak\Model\Order\Email\Sender\OrderSender::send(ABC\Listrak\Model\Order\Email\Sender\Order $order, $forceSyncMode = false) should be compatible with Magento\Sales\Model\Order\Email\Sender\OrderSender::send(Magento\Sales\Model\Order $order, $forceSyncMode = false) in C:\wamp64\www\huf\app\code\ABC\Listrak\Model\Order\Email\Sender\OrderSender.php on line 41

If someone can help with this Thanks

1

Your Class file OrderSender.php content should like this.

namespace ABC\Listrak\Model\Order\Email\Sender;

use Magento\Sales\Model\Order;

class OrderSender extends \Magento\Sales\Model\Order\Email\Sender\OrderSender
{   
    public function __construct(
            \Psr\Log\LoggerInterface $logger
    )
    {
        $this->logger = $logger;
    }

    public function send(Order $order, $forceSyncMode = false)
    {
        $order->setSendEmail(true);

        if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
            if ($this->checkAndSend($order)) {
                $order->setEmailSent(true);
                $this->orderResource->saveAttribute($order, ['send_email', 'email_sent']);
                return true;
            }
        }

        $this->orderResource->saveAttribute($order, 'send_email');

        return false;
    }
}

I have added use Magento\Sales\Model\Order; after namespace ABC\Listrak\Model\Order\Email\Sender;.

1
  • Welcome @Impunkj, happy to help! – kunj May 11 '18 at 12:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.