public function setStockLevel(Unit $unit, array $row, $location = 'web') { $stockKey = $this->_headingKeys->getKey('stock'); if (!is_string($location) && !$location instanceof Location\Location) { throw new \InvalidArgumentException('Location must be either a string or an instance of Location'); } elseif (!array_key_exists($stockKey, $row)) { throw new \LogicException('No stock column in row!'); } $stockLevel = (int) $row[$stockKey]; if ($stockLevel > 0) { $location = $location instanceof Location\Location ? $location : $this->_locations->get($location); $this->_stockManager->setReason($this->_reason); $this->_stockManager->set($unit, $location, $stockLevel); } }
protected function _commit() { $this->_stockManager->commit(); return $this; }