221 $this->_errorInfos = $statusListFactory->create();
222 $this->_localeFormat = $localeFormat;
223 $this->_itemOptionFactory = $itemOptionFactory;
258 parent::beforeSave();
259 $this->setIsVirtual($this->
getProduct()->getIsVirtual());
273 if ($this->
getQuote()->getItemsQty() == $this->
getQuote()->getVirtualItemsQty()) {
292 $this->setStoreId(
$quote->getStoreId());
316 $qty = $this->_localeFormat->getNumber($qty);
317 $qty = $qty > 0 ? $qty : 1;
335 $this->setQtyToAdd($qty);
350 $oldQty = $this->
_getData(self::KEY_QTY);
351 $this->
setData(self::KEY_QTY, $qty);
353 $this->_eventManager->dispatch(
'sales_quote_item_qty_set_after', [
'item' => $this]);
359 if ($this->getUseOldQty()) {
360 $this->
setData(self::KEY_QTY, $oldQty);
375 public function getQtyOptions()
377 $qtyOptions = $this->
getData(
'qty_options');
378 if ($qtyOptions ===
null) {
383 if (is_object(
$option->getProduct())
397 $this->
setData(
'qty_options', $qtyOptions);
413 return $this->
setData(
'qty_options', $qtyOptions);
434 ->setTaxClassId(
$product->getTaxClassId())
440 $this->_eventManager->dispatch(
441 'sales_quote_item_set_product',
442 [
'product' =>
$product,
'quote_item' => $this]
465 $stickWithinParent =
$product->getStickWithinParent();
466 if ($stickWithinParent) {
496 foreach ($options1 as
$option) {
498 if (in_array(
$code, $this->_notRepresentOptions)) {
501 if (!isset($options2[
$code]) || $options2[
$code]->getValue() !=
$option->getValue()) {
516 return $this->quoteItemCompare->compare($this,
$item);
535 return $this->
_getData(self::KEY_PRODUCT_TYPE);
547 return $this->
_getData(self::KEY_PRODUCT_TYPE);
556 public function toArray(array $arrAttributes = [])
558 $data = parent::toArray($arrAttributes);
617 $option = $this->_itemOptionFactory->create()->setData(
$option)->setItem($this);
621 $option = $this->_itemOptionFactory->create()->setData(
631 throw new \Magento\Framework\Exception\LocalizedException(
__(
'We found an invalid item option format.'));
636 $exOption->addData(
$option->getData());
655 $optionProduct =
$option->getProduct();
658 if (isset(
$options[$optionProduct->getId()])) {
662 $this->
getProduct()->getTypeInstance()->updateQtyOption(
696 if (!isset($this->_optionsByCode[
$option->getCode()])) {
699 throw new \Magento\Framework\Exception\LocalizedException(
700 __(
'An item option with code %1 already exists.',
$option->getCode())
715 return $this->_optionsByCode[
$code];
745 unset($this->_options[
$index]);
746 unset($this->_optionsByCode[
$option->getCode()]);
755 $this->_flagOptionsSaved =
true;
771 $this->_flagOptionsSaved = $flag;
794 return parent::afterSave();
806 $this->_quote =
null;
807 $this->_options = [];
808 $this->_optionsByCode = [];
824 $data = $option ? $this->serializer->unserialize(
$option->getValue()) : [];
841 return $this->
setData(
'has_error', $flag);
872 $this->_errorInfos->clear();
889 $this->_errorInfos->addItem($origin,
$code,
$message, $additionalData);
905 return $this->_errorInfos->getItems();
918 $removedItems = $this->_errorInfos->removeItemsByParams(
$params);
919 foreach ($removedItems as
$item) {
920 if (
$item[
'message'] !==
null) {
925 if (!$this->_errorInfos->getItems()) {
939 return $this->
getData(self::KEY_ITEM_ID);
947 return $this->
setData(self::KEY_ITEM_ID, $itemID);
955 return $this->
getData(self::KEY_SKU);
963 return $this->
setData(self::KEY_SKU, $sku);
971 return $this->
getData(self::KEY_QTY);
979 return $this->
getData(self::KEY_NAME);
995 return $this->
getData(self::KEY_PRICE);
1011 return $this->
setData(self::KEY_PRODUCT_TYPE, $productType);
1019 return $this->
getData(self::KEY_QUOTE_ID);
1037 return $this->
getData(self::KEY_PRODUCT_OPTION);
addErrorInfo($origin=null, $code=null, $message=null, $additionalData=null)
_getExtensionAttributes()
elseif(isset( $params[ 'redirect_parent']))
toArray(array $arrAttributes=[])
setExtensionAttributes(\Magento\Quote\Api\Data\CartItemExtensionInterface $extensionAttributes)
removeMessageByText($text)
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
setProductType($productType)
setQuote(\Magento\Quote\Model\Quote $quote)
removeErrorInfosByParams($params)
updateQtyOption(\Magento\Framework\DataObject $option, $value)
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Sales\Model\Status\ListFactory $statusListFactory, \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Quote\Model\Quote\Item\OptionFactory $itemOptionFactory, \Magento\Quote\Model\Quote\Item\Compare $quoteItemCompare, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[], \Magento\Framework\Serialize\Serializer\Json $serializer=null)
compareOptions($options1, $options2)
foreach($product->getExtensionAttributes() ->getBundleProductOptions() as $option) $buyRequest
getData($key='', $index=null)
setData($key, $value=null)
setQtyOptions($qtyOptions)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
setProductOption(\Magento\Quote\Api\Data\ProductOptionInterface $productOption)
representProduct($product)
isDeleted($isDeleted=null)
if(!isset($_GET['name'])) $name