Instead of check here, add it into loop?
```php
foreach ($item->getInventoryUnits() as $i => $unit) {
     if (0 === $i && $unit->getStockable() !== $item->getVariant()) {
         break;
     }

     $unit->setStockable($item->getVariant());
}