code: protected function handleContentChange(SaleInterface $sale)
      {
          $changed = parent::handleContentChange($sale);
  
          if (null !== $margin = $this->marginCalculator->calculateSale($sale)) {
              $amount = $margin->getAmount();
          } else {
              $amount = 0;
          }
  
          if ($sale->getMarginTotal() != $amount) {
              $sale->setMarginTotal($amount);
              $changed = true;
          }
  
          if ($sale->getItemsCount() != $count = $sale->getItems()->count()) {
              $sale->setItemsCount($count);
              $changed = true;
          }
  
          return $changed;
      }
docs: @inheritDoc
  
  @param OrderInterface $sale