Stock/Dispatcher/StockAssignmentDispatcher.php
private function persistAssignment(StockAssignmentInterface $assignment)
    {
        // Remove if empty
        if (0 == $assignment->getSoldQuantity()) {
            $assignment
                ->setSaleItem(null)
                ->setStockUnit(null);

            $this->persistenceHelper->remove($assignment, true);

            return;
        }

        // Persist without scheduling event
        $this->persistenceHelper->persistAndRecompute($assignment, true);
    }
private function persistAssignment(StockAssignmentInterface $assignment)
    {
        // Remove if empty
        if (0 == $assignment->getSoldQuantity()) {
            $assignment
                ->setSaleItem(null)
                ->setStockUnit(null);

            $this->persistenceHelper->remove($assignment, true);

            return;
        }

        // Persist without scheduling event
        $this->persistenceHelper->persistAndRecompute($assignment, true);
    }
Persists (or removes) the stock assignment.

@param StockAssignmentInterface $assignment