英文:
Import Export Profil in Shopware 6.5 - how to use ImportExportBeforeImportRecordEvent
问题
在 Shopware 6.4 中,我们为我们的插件创建了一个单独的导入/导出配置文件,并使用了EntityRepositoryDecorator。在 Shopware 6.5 中,不再存在EntityRepositoryDecorator。目标是在导入数据写入数据库之前更改实体的数据。为此,我们可以使用事件ImportExportBeforeImportRecordEvent,不幸的是,我们没有关于正在导入哪个实体的信息,也无法检查。我们无法为每个单独的实体执行更改数据的代码。
英文:
In Shopware 6.4 we created a separate import / export profile for our plugin and used EntityRepositoryDecorator.
With Shopware 6.5 there is no longer an EntityRepositoryDecorator.
The goal is to change the data of the entity during import before it is written to the database. For this we could use the event ImportExportBeforeImportRecordEvent, unfortunately we have no information about which entity is being imported and cannot check this. We cannot execute the code to change the data for each individual entity.
答案1
得分: 1
你可以从事件提供的配置中获取实体名称。
public function callbackMethodName($event): void
{
$entityName = $event->getConfig()->get('sourceEntity');
// ...
}
参见ProductCategoryPathsSubscriber以获取示例。
英文:
You can get the entity name from the config provided by the event.
public function callbackMethodName $event): void
{
$entityName = $event->getConfig()->get('sourceEntity');
// ...
}
See ProductCategoryPathsSubscriber for an example.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论