/** * @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; }