22
33namespace TemplateProvider \EMailTemplatesImportExport \Model ;
44
5+ use Magento \Framework \App \ObjectManager ;
56use Magento \Store \Api \StoreRepositoryInterface ;
67use Magento \Framework \Json \DecoderInterface ;
78use Magento \Framework \Json \EncoderInterface ;
@@ -65,7 +66,13 @@ class Content implements ContentInterface
6566 */
6667 private CollectionFactory $ collectionFactory ;
6768
69+ /**
70+ * @var \Magento\Framework\ObjectManagerInterface
71+ */
72+ protected $ objectManager ;
73+
6874 public function __construct (
75+ \Magento \Framework \ObjectManagerInterface $ objectManager ,
6976 StoreRepositoryInterface $ storeRepositoryInterface ,
7077 EncoderInterface $ encoderInterface ,
7178 DecoderInterface $ decoderInterface ,
@@ -75,6 +82,7 @@ public function __construct(
7582 DateTime $ dateTime
7683 )
7784 {
85+ $ this ->objectManager = $ objectManager ;
7886 $ this ->storeRepositoryInterface = $ storeRepositoryInterface ;
7987 $ this ->encoderInterface = $ encoderInterface ;
8088 $ this ->decoderInterface = $ decoderInterface ;
@@ -307,14 +315,16 @@ private function importEMailTemplatesFromArray(array $eMailTemplateSource): bool
307315 /** @var \Magento\Email\Model\Template $eMailTemplate */
308316 $ eMailTemplate = $ this ->collectionFactory ->create ()->getItemById ($ eMailTemplateSource ['emailtemplate ' ]['id ' ]);
309317
310- if ($ this ->mode == ContentInterface::EMAIL_TEMPLATES_MODE_SKIP ) {
318+ if ($ eMailTemplate !== null && $ this ->mode == ContentInterface::EMAIL_TEMPLATES_MODE_SKIP ) {
311319 return false ;
312320 }
321+ if ($ eMailTemplate === null ) {
322+ $ eMailTemplate = $ this ->objectManager ->create (\Magento \Email \Model \Template::class);
323+ }
313324
314325 $ eMailTemplateContent = $ eMailTemplateSource ['emailtemplate ' ];
315326
316327 $ eMailTemplate
317- ->setId ($ eMailTemplateContent ['id ' ])
318328 ->setTemplateCode ($ eMailTemplateContent ['template_code ' ])
319329 ->setTemplateText ($ eMailTemplateContent ['template_text ' ])
320330 ->setTemplateStyles ($ eMailTemplateContent ['template_styles ' ])
0 commit comments