Skip to content

Commit fe02648

Browse files
committed
Fix issue 16315: Product save with onthefly index ignores website assignments
1 parent bf03292 commit fe02648

File tree

1 file changed

+14
-0
lines changed
  • app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action

1 file changed

+14
-0
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,24 @@ public function execute($id = null)
8585
$ids = [$id];
8686
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
8787

88+
$select = $this->_connection->select();
89+
$select->from(['e' => $this->_productIndexerHelper->getTable('store')], ['e.store_id'])
90+
->where('c.product_id = ' . $id)
91+
->joinLeft(
92+
['c' => $this->_productIndexerHelper->getTable('catalog_product_website')],
93+
'e.website_id = c.website_id',
94+
[]
95+
);
96+
$storeIds = $this->_connection->fetchCol($select);
97+
8898
$stores = $this->_storeManager->getStores();
8999
foreach ($stores as $store) {
90100
$tableExists = $this->_isFlatTableExists($store->getId());
91101
if ($tableExists) {
102+
if (!in_array($store->getId(), $storeIds)) {
103+
$this->flatItemEraser->deleteProductsFromStore($id, $store->getId());
104+
continue;
105+
}
92106
$this->flatItemEraser->removeDeletedProducts($ids, $store->getId());
93107
$this->flatItemEraser->removeDisabledProducts($ids, $store->getId());
94108
}

0 commit comments

Comments
 (0)