22
22
23
23
use Meta \Catalog \Model \ResourceModel \FacebookCatalogUpdate as FBCatalogUpdateResourceModel ;
24
24
use Magento \Indexer \Model \Indexer ;
25
- use Magento \Framework \Mview \View \ChangelogBatchWalker ;
26
- use Magento \Framework \Mview \View \ChangelogBatchWalkerFactory ;
27
25
use Magento \Framework \Mview \View ;
28
26
use Magento \Indexer \Model \WorkingStateProvider ;
27
+ use Magento \Framework \ObjectManagerInterface ;
29
28
30
29
class FacebookCatalogUpdateFullReindexPlugin
31
30
{
@@ -40,30 +39,30 @@ class FacebookCatalogUpdateFullReindexPlugin
40
39
private $ fbCatalogUpdateResourceModel ;
41
40
42
41
/**
43
- * @var ChangelogBatchWalkerFactory
42
+ * @var WorkingStateProvider
44
43
*/
45
- private $ changelogBatchWalkerFactory ;
44
+ private $ workingStateProvider ;
46
45
47
46
/**
48
- * @var WorkingStateProvider
47
+ * @var ObjectManagerInterface
49
48
*/
50
- private $ workingStateProvider ;
49
+ private $ objectManager ;
51
50
52
51
/**
53
52
* FacebookCatalogUpdateOnIndexerPlugin constructor
54
53
*
55
54
* @param WorkingStateProvider $workingStateProvider
56
55
* @param FBCatalogUpdateResourceModel $fbCatalogUpdateResourceModel
57
- * @param ChangelogBatchWalkerFactory $changelogBatchWalkerFactory
56
+ * @param ObjectManagerInterface $objectManager
58
57
*/
59
58
public function __construct (
60
59
WorkingStateProvider $ workingStateProvider ,
61
60
FBCatalogUpdateResourceModel $ fbCatalogUpdateResourceModel ,
62
- ChangelogBatchWalkerFactory $ changelogBatchWalkerFactory
61
+ ObjectManagerInterface $ objectManager
63
62
) {
64
63
$ this ->workingStateProvider = $ workingStateProvider ;
65
64
$ this ->fbCatalogUpdateResourceModel = $ fbCatalogUpdateResourceModel ;
66
- $ this ->changelogBatchWalkerFactory = $ changelogBatchWalkerFactory ;
65
+ $ this ->objectManager = $ objectManager ;
67
66
}
68
67
69
68
/**
@@ -85,7 +84,7 @@ public function beforeReindexAll(Indexer $subject)
85
84
$ nextVersionId = $ cl ->getVersion ();
86
85
87
86
while ($ currentVersionId < $ nextVersionId ) {
88
- $ walker = $ this ->changelogBatchWalkerFactory -> create (ChangelogBatchWalker::class );
87
+ $ walker = $ this ->getChangelogBatchWalkerInstance ( );
89
88
$ batches = $ walker ->walk ($ cl , $ currentVersionId , $ nextVersionId , $ batchSize );
90
89
91
90
foreach ($ batches as $ ids ) {
@@ -98,6 +97,27 @@ public function beforeReindexAll(Indexer $subject)
98
97
}
99
98
}
100
99
100
+ /**
101
+ * Get class object
102
+ */
103
+ public function getChangelogBatchWalkerInstance ()
104
+ {
105
+ if (class_exists (\Magento \Framework \Mview \View \ChangeLogBatchWalkerFactory::class)) { // @phpstan-ignore-line
106
+ $ changeLogWalkerFactory = $ this ->objectManager ->create (
107
+ \Magento \Framework \Mview \View \ChangeLogBatchWalkerFactory::class // @phpstan-ignore-line
108
+ );
109
+ return $ changeLogWalkerFactory ->create (
110
+ \Magento \Framework \Mview \View \ChangeLogBatchWalker::class // @phpstan-ignore-line
111
+ );
112
+ }
113
+ $ changelogWalkerFactory = $ this ->objectManager ->create (
114
+ \Magento \Framework \Mview \View \ChangelogBatchWalkerFactory::class // @phpstan-ignore-line
115
+ );
116
+ return $ changelogWalkerFactory ->create (
117
+ \Magento \Framework \Mview \View \ChangelogBatchWalker::class // @phpstan-ignore-line
118
+ );
119
+ }
120
+
101
121
/**
102
122
* Checks to run the catalog update plugin
103
123
*
0 commit comments