Stock/Resolver/StockUnitResolver.php
protected function merge(array $cachedUnits, array $fetchedUnits)
    {
        $cachedIds = [];
        foreach ($cachedUnits as $unit) {
            if (null !== $id = $unit->getId()) {
                $cachedIds[] = $unit->getId();
            }
        }

        foreach ($fetchedUnits as $unit) {
            if (in_array($unit->getId(), $cachedIds)) {
                continue;
            }

            if ($this->unitCache->isRemoved($unit)) {
                continue;
            }

            if ($this->persistenceHelper->isScheduledForRemove($unit)) {
                continue;
            }

            $cachedUnits[] = $unit;
        }

        return $cachedUnits;
    }
protected function merge(array $cachedUnits, array $fetchedUnits)
    {
        $cachedIds = [];
        foreach ($cachedUnits as $unit) {
            if (null !== $id = $unit->getId()) {
                $cachedIds[] = $unit->getId();
            }
        }

        foreach ($fetchedUnits as $unit) {
            if (in_array($unit->getId(), $cachedIds)) {
                continue;
            }

            if ($this->unitCache->isRemoved($unit)) {
                continue;
            }

            if ($this->persistenceHelper->isScheduledForRemove($unit)) {
                continue;
            }

            $cachedUnits[] = $unit;
        }

        return $cachedUnits;
    }
Merges the fetched units with the cached units.

@param StockUnitInterface[] $cachedUnits
@param StockUnitInterface[] $fetchedUnits

@return array