public function testExecuteWithIndexerNotWorking() { $ids = [1, 2, 3]; $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(false)); $this->prepareIndexer(); $rowMock = $this->getMock('Magento\\Catalog\\Model\\Indexer\\Category\\Product\\Action\\Rows', ['execute'], [], '', false); $rowMock->expects($this->once())->method('execute')->with($ids, false)->will($this->returnSelf()); $this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock)); $this->model->execute($ids); }
public function testExecuteWithIndexerNotWorking() { $ids = array(1, 2, 3); $this->indexerMock->expects($this->once())->method('load')->with('catalog_category_product')->will($this->returnSelf()); $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(false)); $rowMock = $this->getMock('Magento\\Catalog\\Model\\Indexer\\Category\\Product\\Action\\Rows', array('execute'), array(), '', false); $rowMock->expects($this->once())->method('execute')->with($ids, false)->will($this->returnSelf()); $this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock)); $this->model->execute($ids); }
/** * Execute action for single entity or list of entities * * @param int[] $ids * @return $this */ protected function executeAction($ids) { $ids = array_unique($ids); $indexer = $this->indexerRegistry->get(static::INDEXER_ID); /** @var Product\Action\Rows $action */ $action = $this->rowsActionFactory->create(); if ($indexer->isWorking()) { $action->execute($ids, true); } $action->execute($ids); return $this; }
/** * Factory constructor * * @param \Magento\Framework\ObjectManagerInterface $objectManager * @param string $instanceName */ public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = 'Magento\\Catalog\\Model\\Indexer\\Product\\Category\\Action\\Rows') { parent::__construct($objectManager, $instanceName); }