'catalog_category_save_commit_after' magento2 中也有同样的活动吗?

'catalog_category_save_commit_after' this same event is available in magento2?

我试图让类别 ID 存储在我的自定义 table 中,其中包含一些值,例如 cat_id、custom_value。

我在这里搜索并"catalog_category_prepare_save"在保存现有类别时获取类别对象,但在添加新订单时我将如何获取类别 ID?

请建议 "catalog_category_prepare_save" 的 magento2 中有任何事件吗?或者建议其他方法?

在这里添加我的代码:

events.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="catalog_category_prepare_save">
        <observer name="categoryattributes" instance="Namespace\Module\Observer\Categoryattributes"/>
    </event>
</config>

Categoryattributes.php

<?php
namespace Namespace\Module\Observer;

class Categoryattributes implements \Magento\Framework\Event\ObserverInterface
{
    private $category = null;
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
         $this->category = $observer->getEvent()->getCategory();
    }
}

您可以使用 catalog_category_save_after 事件。

<?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="catalog_category_save_after">
        <observer name="categoryattributes" instance="Namespace\Module\Observer\Categoryattributes"/>
    </event>
  </config>

Categoryattributes.php

<?php
namespace Namespace\Module\Observer;

class Categoryattributes implements \Magento\Framework\Event\ObserverInterface
{
    private $category = null;
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
         $this->category = $observer->getEvent()->getCategory();
    }
}