public function getRequest() { $request = new \Magento\Framework\DataObject(); $request->setQty($this->proxyItem->getQty()); // grouped and downloadable products doesn't have options if ($this->proxyItem->getProduct()->getTypeId() == TypeGrouped::TYPE_CODE || $this->proxyItem->getProduct()->getTypeId() == TypeDownloadable::TYPE_DOWNLOADABLE) { return $request; } /** @var $magentoProduct \Ess\M2ePro\Model\Magento\Product */ $magentoProduct = $this->modelFactory->getObject('Magento\\Product')->setProduct($this->getProduct()); $options = $this->proxyItem->getOptions(); if (empty($options)) { return $request; } if ($magentoProduct->isSimpleType()) { $request->setOptions($options); } else { if ($magentoProduct->isBundleType()) { $request->setBundleOption($options); } else { if ($magentoProduct->isConfigurableType()) { $request->setSuperAttribute($options); } } } return $request; }
/** * @param \Ess\M2ePro\Model\Order\Item\Proxy $that * @return bool */ public function equals(\Ess\M2ePro\Model\Order\Item\Proxy $that) { if (is_null($this->getProductId()) || is_null($that->getProductId())) { return false; } if ($this->getProductId() != $that->getProductId()) { return false; } $thisOptions = $this->getOptions(); $thatOptions = $that->getOptions(); $thisOptionsKeys = array_keys($thisOptions); $thatOptionsKeys = array_keys($thatOptions); $thisOptionsValues = array_values($thisOptions); $thatOptionsValues = array_values($thatOptions); if (count($thisOptions) != count($thatOptions) || count(array_diff($thisOptionsKeys, $thatOptionsKeys)) > 0 || count(array_diff($thisOptionsValues, $thatOptionsValues)) > 0) { return false; } // grouped products have no options, that's why we have to compare associated products $thisAssociatedProducts = $this->getAssociatedProducts(); $thatAssociatedProducts = $that->getAssociatedProducts(); if (count($thisAssociatedProducts) != count($thatAssociatedProducts) || count(array_diff($thisAssociatedProducts, $thatAssociatedProducts)) > 0) { return false; } return true; }