Skip to content

Commit

Permalink
Use id instead of sku
Browse files Browse the repository at this point in the history
This improves the speed of the query.
  • Loading branch information
ah-net committed Mar 27, 2024
1 parent 387f2ef commit 789aecd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Model/Write/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ public function exportStore(Writer $writer, XMLWriter $xml, Store $store, array
foreach ($this->iterator as $index => $data) {
$this->writeProduct($xml, $store->getId(), $data);
// Flush every so often
if ($index % 100 === 0) {
if ($index % 2 === 0) {
$writer->flush();
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function getStockItemMap(Collection|StockCollection $collection): array
return [];
}

$skus = $collection->getAllSkus();
$entityIds = $collection->getAllIds();

$store = $collection->getStore();
$sourceCodes = $this->getSourceCodesForStore($store);
Expand Down Expand Up @@ -207,7 +207,7 @@ public function getStockItemMap(Collection|StockCollection $collection): array
'backorders',
]
)
->where("$productTableName.sku IN (?)", $skus)
->where("$productTableName.entity_id IN (?)", $entityIds)
->columns(
[
'product_entity_id' => "$productTableName.entity_id",
Expand Down
1 change: 1 addition & 0 deletions Model/Write/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ protected function determineWriters($type = null) : void
if ($type === null) {
unset ($this->writers['stock']);
unset($this->writers['price']);
unset($this->writers['categories']);
} else {
foreach ($this->writers as $key => $value) {
if($type !== $key) {
Expand Down

0 comments on commit 789aecd

Please sign in to comment.