magento 如何从脚本发送订单确认电子邮件

lf5gs5x2  于 2022-11-12  发布在  其他
关注(0)|答案(2)|浏览(155)

当我尝试从Magento中的根脚本发送电子邮件时,我得到以下错误:

Fatal error:  Uncaught exception 'BadMethodCallException' with message 'Missing required argument $debugHintsPath of Magento\Developer\Model\TemplateEngine\Plugin\DebugHints.' in
/var/www/html/2x/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:45
Stack trace:
0 /var/www/html/2x/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82):
Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Develop...', Array, Array)
1 /var/www/html/2x/vendor/magento/framework/ObjectManager/ObjectManager.php(71):
Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Develop...')
2 /var/www/html/2x/vendor/magento/framework/Interception/PluginList/PluginList.php(234):
Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Develop...')
3 /var/www/html/2x/vendor/magento/framework/Interception/Interceptor.php(149):
Magento\Framework\Interception\PluginList\PluginList->getPlugin('Magento\\Framewo...', 'debug_hints')
4 /var/www/html/2x/var/generati in /var/www/html/2x/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php
on line 45

下面是我使用的代码:

$orderid = '000000003';
$order = $obj->create('Magento\Sales\Model\Order')->loadByIncrementId($orderid);
// print_r($order->getData());

$obj->create('Magento\Sales\Model\Order\Email\Sender\OrderSender')->send($order,true);
drkbr07n

drkbr07n1#

如果需要,您还可以更改邮件的收件人:

$orderid = '000000338';
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $order = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($orderid);
        $order->setCustomerEmail('custom@mail.com');
        $objectManager->create('Magento\Sales\Model\OrderNotifier')->notify($order);
twh00eeo

twh00eeo2#

尝试使用

$orderid = '000000003';
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($orderid);
$objectManager->create('Magento\Sales\Model\OrderNotifier')->notify($order);

相关问题