@@ -421,7 +421,7 @@ public function __construct(
421
421
422
422
$ this ->_initMessageTemplates ();
423
423
424
- $ this ->_initProductsSku ()-> _initOldCustomOptions () ;
424
+ $ this ->_initProductsSku ();
425
425
}
426
426
427
427
/**
@@ -606,6 +606,9 @@ protected function _initOldCustomOptions()
606
606
'option_title.store_id = ? ' ,
607
607
$ storeId
608
608
);
609
+ if (!empty ($ this ->_newOptionsOldData )) {
610
+ $ this ->_optionCollection ->addProductToFilter (array_keys ($ this ->_newOptionsOldData ));
611
+ }
609
612
610
613
$ this ->_byPagesIterator ->iterate ($ this ->_optionCollection , $ this ->_pageSize , [$ addCustomOptions ]);
611
614
}
@@ -614,6 +617,20 @@ protected function _initOldCustomOptions()
614
617
return $ this ;
615
618
}
616
619
620
+ /**
621
+ * Get existing custom options data
622
+ *
623
+ * @return array
624
+ */
625
+ private function getOldCustomOptions (): array
626
+ {
627
+ if ($ this ->_oldCustomOptions === null ) {
628
+ $ this ->_initOldCustomOptions ();
629
+ }
630
+
631
+ return $ this ->_oldCustomOptions ;
632
+ }
633
+
617
634
/**
618
635
* Imported entity type code getter
619
636
*
@@ -717,9 +734,9 @@ protected function _findOldOptionsWithTheSameTitles()
717
734
$ errorRows = [];
718
735
foreach ($ this ->_newOptionsOldData as $ productId => $ options ) {
719
736
foreach ($ options as $ outerData ) {
720
- if (isset ($ this ->_oldCustomOptions [$ productId ])) {
737
+ if (isset ($ this ->getOldCustomOptions () [$ productId ])) {
721
738
$ optionsCount = 0 ;
722
- foreach ($ this ->_oldCustomOptions [$ productId ] as $ innerData ) {
739
+ foreach ($ this ->getOldCustomOptions () [$ productId ] as $ innerData ) {
723
740
if (count ($ outerData ['titles ' ]) == count ($ innerData ['titles ' ])) {
724
741
$ outerTitles = $ outerData ['titles ' ];
725
742
$ innerTitles = $ innerData ['titles ' ];
@@ -753,8 +770,8 @@ protected function _findNewOldOptionsTypeMismatch()
753
770
$ errorRows = [];
754
771
foreach ($ this ->_newOptionsOldData as $ productId => $ options ) {
755
772
foreach ($ options as $ outerData ) {
756
- if (isset ($ this ->_oldCustomOptions [$ productId ])) {
757
- foreach ($ this ->_oldCustomOptions [$ productId ] as $ innerData ) {
773
+ if (isset ($ this ->getOldCustomOptions () [$ productId ])) {
774
+ foreach ($ this ->getOldCustomOptions () [$ productId ] as $ innerData ) {
758
775
if (count ($ outerData ['titles ' ]) == count ($ innerData ['titles ' ])) {
759
776
$ outerTitles = $ outerData ['titles ' ];
760
777
$ innerTitles = $ innerData ['titles ' ];
@@ -784,9 +801,9 @@ protected function _findNewOldOptionsTypeMismatch()
784
801
protected function _findExistingOptionId (array $ newOptionData , array $ newOptionTitles )
785
802
{
786
803
$ productId = $ newOptionData ['product_id ' ];
787
- if (isset ($ this ->_oldCustomOptions [$ productId ])) {
804
+ if (isset ($ this ->getOldCustomOptions () [$ productId ])) {
788
805
ksort ($ newOptionTitles );
789
- $ existingOptions = $ this ->_oldCustomOptions [$ productId ];
806
+ $ existingOptions = $ this ->getOldCustomOptions () [$ productId ];
790
807
foreach ($ existingOptions as $ optionId => $ optionData ) {
791
808
if ($ optionData ['type ' ] == $ newOptionData ['type ' ]
792
809
&& $ optionData ['titles ' ][Store::DEFAULT_STORE_ID ] == $ newOptionTitles [Store::DEFAULT_STORE_ID ]
0 commit comments