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 ;
25
+ use Magento \Framework \Mview \View \ChangelogBatchWalker ;
26
+ use Magento \Framework \Mview \View \ChangelogBatchWalkerFactory ;
27
27
use Magento \Framework \Mview \View ;
28
28
use Magento \Indexer \Model \WorkingStateProvider ;
29
29
@@ -40,9 +40,9 @@ class FacebookCatalogUpdateFullReindexPlugin
40
40
private $ fbCatalogUpdateResourceModel ;
41
41
42
42
/**
43
- * @var ChangeLogBatchWalkerFactory
43
+ * @var ChangelogBatchWalkerFactory
44
44
*/
45
- private $ changeLogBatchWalkerFactory ;
45
+ private $ changelogBatchWalkerFactory ;
46
46
47
47
/**
48
48
* @var WorkingStateProvider
@@ -54,16 +54,16 @@ class FacebookCatalogUpdateFullReindexPlugin
54
54
*
55
55
* @param WorkingStateProvider $workingStateProvider
56
56
* @param FBCatalogUpdateResourceModel $fbCatalogUpdateResourceModel
57
- * @param ChangeLogBatchWalkerFactory $changeLogBatchWalkerFactory
57
+ * @param ChangelogBatchWalkerFactory $changelogBatchWalkerFactory
58
58
*/
59
59
public function __construct (
60
- WorkingStateProvider $ workingStateProvider ,
60
+ WorkingStateProvider $ workingStateProvider ,
61
61
FBCatalogUpdateResourceModel $ fbCatalogUpdateResourceModel ,
62
- ChangeLogBatchWalkerFactory $ changeLogBatchWalkerFactory
62
+ ChangelogBatchWalkerFactory $ changelogBatchWalkerFactory
63
63
) {
64
64
$ this ->workingStateProvider = $ workingStateProvider ;
65
65
$ this ->fbCatalogUpdateResourceModel = $ fbCatalogUpdateResourceModel ;
66
- $ this ->changeLogBatchWalkerFactory = $ changeLogBatchWalkerFactory ;
66
+ $ this ->changelogBatchWalkerFactory = $ changelogBatchWalkerFactory ;
67
67
}
68
68
69
69
/**
@@ -77,22 +77,24 @@ public function beforeReindexAll(Indexer $subject)
77
77
if (!$ this ->shouldSaveUpdates ($ subject )) {
78
78
return ;
79
79
}
80
-
80
+
81
81
$ batchSize = View::DEFAULT_BATCH_SIZE ;
82
82
$ view = $ subject ->getView ();
83
83
$ cl = $ view ->getChangelog ();
84
84
$ currentVersionId = (int )$ view ->getState ()->getVersionId ();
85
85
$ nextVersionId = $ cl ->getVersion ();
86
86
87
87
while ($ currentVersionId < $ nextVersionId ) {
88
- $ walker = $ this ->changeLogBatchWalkerFactory ->create (ChangeLogBatchWalker ::class);
89
- $ ids = $ walker ->walk ($ cl , $ currentVersionId , $ nextVersionId , $ batchSize );
88
+ $ walker = $ this ->changelogBatchWalkerFactory ->create (ChangelogBatchWalker ::class);
89
+ $ batches = $ walker ->walk ($ cl , $ currentVersionId , $ nextVersionId , $ batchSize );
90
90
91
- if (empty ($ ids )) {
92
- break ;
91
+ foreach ($ batches as $ ids ) {
92
+ if (empty ($ ids )) {
93
+ break ;
94
+ }
95
+ $ currentVersionId += $ batchSize ;
96
+ $ this ->fbCatalogUpdateResourceModel ->addProductsWithChildren ($ ids , 'update ' );
93
97
}
94
- $ currentVersionId += $ batchSize ;
95
- $ this ->fbCatalogUpdateResourceModel ->addProductsWithChildren ($ ids , 'update ' );
96
98
}
97
99
}
98
100
0 commit comments