订单成功后,我想将订单数据保存在自定义表中。app / code / VendorName / Checkout / etc / event.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_onepage_controller_success_action">
<observer name="MyObserver" instance="VendorName\Checkout\Observer\MyObserver" />
</event>
</config>
app / code / VendorName / Checkout / Observer / MyObserver.php
<?php
namespace VendorName\Checkout\Observer;
use Magento\Framework\Event\ObserverInterface;
class MyObserver implements ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
$orderIds = $observer->getEvent()->getOrderIds();
echo $orderId = $orderIds[0]; exit;
}
}
事件未触发成功。phtml被重定向。
慕码人8056858