/** * Register option code * * @param \Magento\Sales\Model\Quote\Item\Option $option * @return $this * @throws \Magento\Framework\Model\Exception */ protected function _addOptionCode($option) { if (!isset($this->_optionsByCode[$option->getCode()])) { $this->_optionsByCode[$option->getCode()] = $option; } else { throw new \Magento\Framework\Model\Exception(__('An item option with code %1 already exists.', $option->getCode())); } return $this; }