Skip to content

Commit 8f62368

Browse files
MAGETWO-65388: Indexation process in non-locking way for stock indexer
1 parent 37a34dd commit 8f62368

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Stock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public function __construct(
3939
\Magento\Indexer\Model\Indexer\StateFactory $stateFactory = null,
4040
\Magento\Indexer\Model\ResourceModel\FrontendResource $indexerStockFrontendResource = null
4141
) {
42+
parent::__construct($context, $tableStrategy, $eavConfig, $scopeConfig, $connectionName, $stateFactory);
4243
$this->indexerStockFrontendResource = $indexerStockFrontendResource ?: ObjectManager::getInstance()
4344
->get(\Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\FrontendResource::class);
44-
parent::__construct($context, $tableStrategy, $eavConfig, $scopeConfig, $connectionName, $stateFactory);
4545
}
4646

4747
/**

app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ public function __construct(
105105
\Magento\Indexer\Model\ResourceModel\FrontendResource $indexerFrontendResource = null,
106106
\Magento\Indexer\Model\ResourceModel\FrontendResource $indexerStockFrontendResource = null
107107
) {
108-
109-
$this->indexerStockFrontendResource = $indexerStockFrontendResource ?: ObjectManager::getInstance()
110-
->get(\Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\FrontendResource::class);
111108
parent::__construct(
112109
$entityFactory,
113110
$logger,
@@ -133,6 +130,8 @@ public function __construct(
133130
$metadataPool,
134131
$indexerFrontendResource
135132
);
133+
$this->indexerStockFrontendResource = $indexerStockFrontendResource ?: ObjectManager::getInstance()
134+
->get(\Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\FrontendResource::class);
136135
}
137136

138137
/**

app/code/Magento/Bundle/Test/Unit/Model/ResourceModel/Selection/CollectionTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\Validator\UniversalFactory;
1313
use Magento\Eav\Model\Entity\AbstractEntity;
1414
use Magento\Framework\DB\Adapter\AdapterInterface;
15+
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
1516
use Magento\Framework\DB\Select;
1617

1718
/**
@@ -84,6 +85,9 @@ protected function setUp()
8485
$this->select = $this->getMockBuilder(Select::class)
8586
->disableOriginalConstructor()
8687
->getMock();
88+
$factory = $this->getMockBuilder(ProductLimitationFactory::class)
89+
->setMethods(['create'])
90+
->getMock();
8791

8892
$this->storeManager->expects($this->any())
8993
->method('getStore')
@@ -109,6 +113,7 @@ protected function setUp()
109113
[
110114
'storeManager' => $this->storeManager,
111115
'universalFactory' => $this->universalFactory,
116+
'productLimitationFactory' => $factory,
112117
'indexerStockFrontendResource' => $this->frontendResource
113118
]
114119
);
@@ -122,10 +127,11 @@ public function testAddQuantityFilter()
122127
->willReturn($tableName);
123128
$this->select->expects($this->once())
124129
->method('joinInner')
125-
->with(['stock' => $tableName],
130+
->with(
131+
['stock' => $tableName],
126132
'selection.product_id = stock.product_id',
127-
[])
128-
->willReturnSelf();
133+
[]
134+
)->willReturnSelf();
129135
$this->assertEquals($this->model, $this->model->addQuantityFilter());
130136
}
131137
}

0 commit comments

Comments
 (0)