code: 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;
      }
docs: Merges the fetched units with the cached units.
  
  @param StockUnitInterface[] $cachedUnits
  @param StockUnitInterface[] $fetchedUnits
  
  @return array