Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Smile-SA/elasticsuite#1223 and improves select statement #1225

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,12 @@ public function loadInventoryData($storeId, $productIds)
$tableName = $this->stockIndexTableProvider->execute($stockId);

$select = $this->getConnection()->select()
->from(['product' => $this->getTable('catalog_product_entity')], [])
->join(
['stock_index' => $tableName],
'product.sku = stock_index.' . IndexStructure::SKU,
[
'product_id' => 'product.entity_id',
'stock_status' => 'stock_index.' . IndexStructure::IS_SALABLE,
'qty' => 'stock_index.' . IndexStructure::QUANTITY,
]
);
->from($tableName, [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will only work if you're only using the default stock :

  • the table inventory_stock_1 is actually a view based on a join of cataloginventory_stock and catalog_product_entity so it does provide the product_id
  • any subsequent stock index table will only have columns sku, quantity and is_salable

Performance loss due to the extra join is negligible if not non-existent if only using the default stock.

'product_id' => 'product_id',
'stock_status' => IndexStructure::IS_SALABLE,
'qty' => IndexStructure::QUANTITY,
])
->where('product_id IN(?)', $productIds);

return $this->getConnection()->fetchAll($select);
}
Expand Down