25 private static $maxVersionQueryBatch = 100000;
60 private $changelogBatchSize;
78 array $changelogBatchSize = []
85 $this->changelogBatchSize = $changelogBatchSize;
86 parent::__construct(
$data);
96 return $this->
getData($this->_idFieldName);
119 $this->_idFieldName =
$name;
140 return $this->
getData(
'action_class');
150 return $this->
getData(
'group');
160 return $this->
getData(
'subscriptions');
172 $view = $this->config->getView($viewId);
173 if (empty($view) || empty($view[
'view_id']) || $view[
'view_id'] != $viewId) {
174 throw new \InvalidArgumentException(
"{$viewId} view does not exist.");
177 $this->
setId($viewId);
199 $subscriptionInstance = $this->subscriptionFactory->create(
202 'tableName' => $subscriptionConfig[
'name'],
203 'columnName' => $subscriptionConfig[
'column'],
204 'subscriptionModel' => !empty($subscriptionConfig[
'subscription_model'])
205 ? $subscriptionConfig[
'subscription_model']
209 $subscriptionInstance->create();
214 }
catch (\Exception $e) {
235 $subscriptionInstance = $this->subscriptionFactory->create(
238 'tableName' => $subscriptionConfig[
'name'],
239 'columnName' => $subscriptionConfig[
'column'],
240 'subscriptionModel' => !empty($subscriptionConfig[
'subscriptionModel'])
241 ? $subscriptionConfig[
'subscriptionModel']
245 $subscriptionInstance->remove();
250 }
catch (\Exception $e) {
268 $currentVersionId = $this->
getChangelog()->getVersion();
272 $lastVersionId = (int) $this->
getState()->getVersionId();
278 $versionBatchSize = self::$maxVersionQueryBatch;
279 $batchSize = isset($this->changelogBatchSize[$this->
getChangelog()->getViewId()])
280 ? $this->changelogBatchSize[$this->
getChangelog()->getViewId()]
283 for ($vsFrom = $lastVersionId; $vsFrom < $currentVersionId; $vsFrom += $versionBatchSize) {
285 $versionTo = min($currentVersionId, $vsFrom + $versionBatchSize);
286 $ids = $this->
getChangelog()->getList($vsFrom, $versionTo);
290 $chunks = array_chunk($ids, $batchSize);
291 foreach ($chunks as $ids) {
292 $action->execute($ids);
300 $this->
getState()->setVersionId($currentVersionId)->setStatus($statusToRestore)->save();
301 }
catch (\Exception $exception) {
306 $this->
getState()->setStatus($statusToRestore)->save();
360 if (!$this->state->getViewId()) {
361 $this->state->loadByView($this->
getId());
395 return $this->
getState()->getStatus() == \Magento\Framework\Mview\View\StateInterface::STATUS_IDLE;
405 return $this->
getState()->getStatus() == \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING;
415 return $this->
getState()->getStatus() == \Magento\Framework\Mview\View\StateInterface::STATUS_SUSPENDED;
425 return $this->
getState()->getUpdated();
435 if (!$this->changelog->getViewId()) {
436 $this->changelog->setViewId($this->
getId());
getData($key='', $index=null)
setState(View\StateInterface $state)
setData($key, $value=null)
__construct(ConfigInterface $config, ActionFactory $actionFactory, View\StateInterface $state, View\ChangelogInterface $changelog, SubscriptionFactory $subscriptionFactory, array $data=[], array $changelogBatchSize=[])
if(!isset($_GET['name'])) $name