private function getOptions(Ess_M2ePro_Model_Magento_Product $magentoProduct) { $variation = $this->proxyItem->getLowerCasedVariation(); $magentoOptions = $magentoProduct->getProductVariationsForOrder(); // Variation info unavailable - return first value for each required option // --------------- if (empty($variation)) { $firstOptions = array(); foreach ($magentoOptions as $option) { $firstOptions[$option['option_id']] = $option['values'][0]['value_id']; } return $firstOptions; } // --------------- // Map variation with magento options // --------------- $mappedOptions = array(); foreach ($magentoOptions as $option) { $optionValueLabel = $this->getMappedOptionValueLabel($variation, $option['labels']); if ($optionValueLabel == '') { continue; } $optionValueId = $this->getMappedOptionValueId($optionValueLabel, $option['values']); if (is_null($optionValueId)) { continue; } $mappedOptions[$option['option_id']] = $optionValueId; } // --------------- return $mappedOptions; }
public function equals(Ess_M2ePro_Model_Order_Item_Proxy $that) { if (is_null($this->getProduct()->getId()) || is_null($that->getProduct()->getId())) { return false; } if ($this->getProduct()->getId() != $that->getProduct()->getId()) { return false; } $thisVariations = $this->getLowerCasedVariation(); $thatVariations = $that->getLowerCasedVariation(); $thisVariationsKeys = array_keys($thisVariations); $thatVariationsKeys = array_keys($thatVariations); $thisVariationValues = array_values($thisVariations); $thatVariationValues = array_values($thatVariations); if (count($thisVariations) == count($thatVariations) && count(array_diff($thisVariationsKeys, $thatVariationsKeys)) <= 0 && count(array_diff($thisVariationValues, $thatVariationValues)) <= 0) { return true; } return false; }