Improve performance of BulkInventoryTransfer
Open
@phoenix128 is already working on this.
Since Mar 16, 2019.
Performance
- Dominant language
- PHP
- Stars
- 357
- Forks
- 262
- PR merge metrics
- No merged PRs in 30d
Description
\Magento\InventoryCatalog\Model\ResourceModel\BulkInventoryTransfer
/**
* Assign sources to products
* @param array $skus
* @param string $originSource
* @param string $destinationSource
* @param bool $unassignFromOrigin
* @return void
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function execute(
array $skus,
string $originSource,
string $destinationSource,
bool $unassignFromOrigin
): void {
$connection = $this->resourceConnection->getConnection();
$types = $this->getProductTypesBySkus->execute($skus);
$connection->beginTransaction();
foreach ($types as $sku => $type) {
if ($this->isSourceItemManagementAllowedForProductType->execute($type)) {
$this->transferInventory($sku, $originSource, $destinationSource);
}
}
Here we iterate over SKUs array checking whether isSourceItemManagementAllowedForProductType and if so we proceed with transferring , which is inefficient from the performance point of view.
So that we have to collect all transferable SKUs and transfer them in a scope of single operation
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.