magento / magento/inventory

Improve performance of BulkInventoryTransfer

Open
#1,983 3 comments 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.