/** * Mark Product flat indexer as invalid * * @return void */ public function markIndexerAsInvalid() { if (!$this->_state->isFlatEnabled()) { return; } $this->getIndexer()->invalidate(); }
/** * @param bool $isFlat * @param string $path * @param mixed $default * @param array $inputData * @param array $outputData * @dataProvider aroundGetDataProvider */ public function testAroundGet($isFlat, $path, $default, $inputData, $outputData) { $closureMock = function () use($inputData) { return $inputData; }; $this->_stateMock->expects($this->once())->method('isFlatEnabled')->will($this->returnValue($isFlat)); $this->assertEquals($outputData, $this->model->aroundGet($this->subjectMock, $closureMock, $path, $default)); }
/** * Around get handler * * @param \Magento\Indexer\Model\Config\Data $subject * @param callable $proceed * @param string $path * @param string $default * * @return mixed|null * @SuppressWarnings(PHPMD.UnusedFormalParameter) * */ public function aroundGet(\Magento\Indexer\Model\Config\Data $subject, \Closure $proceed, $path = null, $default = null) { $data = $proceed($path, $default); if (!$this->_state->isFlatEnabled()) { $indexerId = \Magento\Catalog\Model\Indexer\Product\Flat\Processor::INDEXER_ID; if (!$path && isset($data[$indexerId])) { unset($data[$indexerId]); } elseif ($path) { list($firstKey, ) = explode('/', $path); if ($firstKey == $indexerId) { $data = $default; } } } return $data; }
/** * @magentoDbIsolation enabled * @magentoAppIsolation enabled * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 * @magentoDataFixture Magento/Catalog/_files/product_simple.php */ public function testReindexAll() { $this->assertTrue($this->_state->isFlatEnabled()); $this->_processor->reindexAll(); $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Model\\CategoryFactory'); $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Block\\Product\\ListProduct'); $category = $categoryFactory->create()->load(2); $layer = $listProduct->getLayer(); $layer->setCurrentCategory($category); $productCollection = $layer->getProductCollection(); $this->assertCount(1, $productCollection); /** @var $product \Magento\Catalog\Model\Product */ foreach ($productCollection as $product) { $this->assertEquals('Simple Product', $product->getName()); $this->assertEquals('Short description', $product->getShortDescription()); } }
public function testReindexListForce() { $ids = [1]; $this->_stateMock->expects($this->once())->method('isFlatEnabled')->willReturn(true); $indexerMock = $this->getMockBuilder('Magento\\Indexer\\Model\\Indexer')->disableOriginalConstructor()->getMock(); $this->indexerRegistryMock->expects($this->any())->method('get')->with(Processor::INDEXER_ID)->willReturn($indexerMock); $indexerMock->expects($this->any())->method('isScheduled')->willReturn(true); $indexerMock->expects($this->any())->method('reindexList')->with($ids)->willReturnSelf(); $this->_model->reindexList($ids, true); }
/** * Initialize collection select * Redeclared for remove entity_type_id condition * in catalog_product_entity we store just products * * @return $this */ protected function _initSelect() { if ($this->isEnabledFlat()) { $this->getSelect()->from([self::MAIN_TABLE_ALIAS => $this->getEntity()->getFlatTableName()], null)->columns(['status' => new \Zend_Db_Expr(ProductStatus::STATUS_ENABLED)]); $this->addAttributeToSelect($this->getResource()->getDefaultAttributes()); if ($this->_catalogProductFlatState->getFlatIndexerHelper()->isAddChildData()) { $this->getSelect()->where('e.is_child=?', 0); $this->addAttributeToSelect(['child_id', 'is_child']); } } else { $this->getSelect()->from([self::MAIN_TABLE_ALIAS => $this->getEntity()->getEntityTable()]); } return $this; }
/** * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testIsEnabled() { $this->assertTrue($this->_state->isFlatEnabled()); }
/** * Test mark indexer as invalid if disabled */ public function testMarkDisabledIndexerAsInvalid() { $this->_stateMock->expects($this->once())->method('isFlatEnabled')->will($this->returnValue(false)); $this->_indexerMock->expects($this->never())->method('invalidate'); $this->_model->markIndexerAsInvalid(); }
/** * Initialize collection select * Redeclared for remove entity_type_id condition * in catalog_product_entity we store just products * * @return $this */ protected function _initSelect() { if ($this->isEnabledFlat()) { $this->getSelect()->from(array(self::MAIN_TABLE_ALIAS => $this->getEntity()->getFlatTableName()), null)->columns(array('status' => new \Zend_Db_Expr(ProductStatus::STATUS_ENABLED))); $this->addAttributeToSelect(array('entity_id', 'type_id', 'attribute_set_id')); if ($this->_catalogProductFlatState->getFlatIndexerHelper()->isAddChildData()) { $this->getSelect()->where('e.is_child=?', 0); $this->addAttributeToSelect(array('child_id', 'is_child')); } } else { $this->getSelect()->from(array(self::MAIN_TABLE_ALIAS => $this->getEntity()->getEntityTable())); } return $this; }
/** * @magentoDbIsolation enabled * @magentoAppIsolation enabled * @magentoAppArea adminhtml * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testEnableProductFlat() { $this->assertTrue($this->_state->isFlatEnabled()); $this->assertTrue($this->_processor->getIndexer()->isInvalid()); }
public function testGetIndexer() { $this->assertInstanceOf('\\Magento\\Catalog\\Helper\\Product\\Flat\\Indexer', $this->_model->getFlatIndexerHelper()); }