/** * Synchronize status for indexers * * @param \Magento\Indexer\Model\Indexer\State $state * @return \Magento\Indexer\Model\Indexer\State */ public function afterSetStatus(\Magento\Indexer\Model\Indexer\State $state) { if (in_array($state->getIndexerId(), $this->indexerIds)) { $indexerId = $state->getIndexerId() == \Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID ? \Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID : \Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID; $relatedIndexerState = $this->state->loadByIndexer($indexerId); $relatedIndexerState->setData('status', $state->getStatus()); $relatedIndexerState->save(); } return $state; }
/** * Process flat enabled mode change * * @return void */ public function processValue() { if ((bool) $this->getValue() != (bool) $this->getOldValue()) { if ((bool) $this->getValue()) { $this->indexerState->loadByIndexer(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID); $this->indexerState->setStatus(\Magento\Indexer\Model\Indexer\State::STATUS_INVALID); $this->indexerState->save(); } else { $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)->setScheduled(false); } } }
/** * Process flat enabled mode change * * @return void */ public function processValue() { if ((bool) $this->getValue() != (bool) $this->getOldValue()) { if ((bool) $this->getValue()) { $this->indexerState->loadByIndexer(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::INDEXER_ID); $this->indexerState->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); $this->indexerState->save(); } else { $this->_productFlatIndexerProcessor->getIndexer()->setScheduled(false); } } }
/** * @param string $oldValue * @param string $value * @dataProvider dataProviderProcessValueOff */ public function testProcessValueOff($oldValue, $value) { $this->configMock->expects($this->once())->method('getValue')->with(null, 'default')->will($this->returnValue($oldValue)); $this->model->setValue($value); $this->indexerStateMock->expects($this->never())->method('loadByIndexer'); $this->indexerStateMock->expects($this->never())->method('setStatus'); $this->indexerStateMock->expects($this->never())->method('save'); $indexerMock = $this->getMockForAbstractClass('Magento\\Framework\\Indexer\\IndexerInterface', [], '', false, false, true, ['setScheduled', '__wakeup']); $indexerMock->expects($this->once())->method('setScheduled')->with(false); $this->indexerProcessorMock->expects($this->once())->method('getIndexer')->will($this->returnValue($indexerMock)); $this->model->processValue(); }
/** * Return related state object * * @return Indexer\State */ public function getState() { if (!$this->state) { $this->state = $this->stateFactory->create(); $this->state->loadByIndexer($this->getId()); } return $this->state; }
/** * {@inheritdoc} */ public function save() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'save'); if (!$pluginInfo) { return parent::save(); } else { return $this->___callPlugins('save', func_get_args(), $pluginInfo); } }
/** * @param string $oldValue * @param string $value * @dataProvider dataProviderProcessValueOff */ public function testProcessValueOff($oldValue, $value) { $this->configMock->expects($this->once())->method('getValue')->with(null, 'default')->will($this->returnValue($oldValue)); $this->model->setValue($value); $this->indexerStateMock->expects($this->never())->method('loadByIndexer'); $this->indexerStateMock->expects($this->never())->method('setStatus'); $this->indexerStateMock->expects($this->never())->method('save'); $this->indexerRegistry->expects($this->once())->method('get')->with('catalog_category_flat')->willReturn($this->flatIndexer); $this->flatIndexer->expects($this->once())->method('setScheduled')->with(false); $this->model->processValue(); }
/** * Synchronize status for indexers * * @param State $state * @return State */ public function afterSave(State $state) { if (in_array($state->getIndexerId(), $this->indexerIds)) { $indexerId = $state->getIndexerId() === Product::INDEXER_ID ? Category::INDEXER_ID : Product::INDEXER_ID; $relatedIndexerState = $this->state->loadByIndexer($indexerId); if ($relatedIndexerState->getStatus() !== $state->getStatus()) { $relatedIndexerState->setData('status', $state->getStatus()); $relatedIndexerState->save(); } } return $state; }
/** * {@inheritdoc} */ public function offsetGet($offset) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'offsetGet'); if (!$pluginInfo) { return parent::offsetGet($offset); } else { return $this->___callPlugins('offsetGet', func_get_args(), $pluginInfo); } }
public function testSetStatus() { $setData = 'data'; $this->model->setStatus($setData); $this->assertEquals($setData, $this->model->getStatus()); }