コード例 #1
0
ファイル: IndexerState.php プロジェクト: aiesh/magento2
 /**
  * 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;
 }
コード例 #2
0
ファイル: Mode.php プロジェクト: nja78/magento2
 /**
  * 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);
         }
     }
 }
コード例 #3
0
ファイル: Mode.php プロジェクト: whoople/magento2-testing
 /**
  * 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);
         }
     }
 }
コード例 #4
0
ファイル: ModeTest.php プロジェクト: pradeep-wagento/magento2
 /**
  * @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();
 }
コード例 #5
0
ファイル: Indexer.php プロジェクト: shabbirvividads/magento2
 /**
  * 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;
 }
コード例 #6
0
 /**
  * {@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);
     }
 }
コード例 #7
0
ファイル: ModeTest.php プロジェクト: shabbirvividads/magento2
 /**
  * @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();
 }
コード例 #8
0
 /**
  * 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;
 }
コード例 #9
0
 /**
  * {@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);
     }
 }
コード例 #10
0
 public function testSetStatus()
 {
     $setData = 'data';
     $this->model->setStatus($setData);
     $this->assertEquals($setData, $this->model->getStatus());
 }