private function match() { $this->validate(); /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Matcher_Attribute $attributeMatcher */ $attributeMatcher = Mage::getModel('M2ePro/Amazon_Listing_Product_Variation_Matcher_Attribute'); if (!is_null($this->magentoProduct)) { if ($this->magentoProduct->isGroupedType()) { $this->matchedTheme = null; return $this; } $attributeMatcher->setMagentoProduct($this->magentoProduct); } if (!empty($this->sourceAttributes)) { $attributeMatcher->setSourceAttributes($this->sourceAttributes); $attributeMatcher->canUseDictionary(false); } foreach ($this->themes as $themeName => $themeAttributes) { $attributeMatcher->setDestinationAttributes($themeAttributes['attributes']); if ($attributeMatcher->isAmountEqual() && $attributeMatcher->isFullyMatched()) { $this->matchedTheme = $themeName; break; } } return $this; }
public function prepareAssociatedProducts(array $associatedProducts) { if ($this->magentoProduct->isSimpleType() || $this->magentoProduct->isDownloadableType()) { return array($this->magentoProduct->getProductId()); } if ($this->magentoProduct->isBundleType()) { $bundleAssociatedProducts = array(); foreach ($associatedProducts as $key => $productIds) { $bundleAssociatedProducts[$key] = reset($productIds); } return $bundleAssociatedProducts; } if ($this->magentoProduct->isConfigurableType()) { $configurableAssociatedProducts = array(); foreach ($associatedProducts as $productIds) { if (count($configurableAssociatedProducts) == 0) { $configurableAssociatedProducts = $productIds; } else { $configurableAssociatedProducts = array_intersect($configurableAssociatedProducts, $productIds); } } if (count($configurableAssociatedProducts) != 1) { throw new LogicException('There is no associated product found for configurable product.'); } return $configurableAssociatedProducts; } if ($this->magentoProduct->isGroupedType()) { return array_values($associatedProducts); } return array(); }
private function match() { $this->validate(); if (!is_null($this->magentoProduct) && $this->magentoProduct->isGroupedType()) { $channelAttribute = reset($this->destinationAttributes); $this->matchedAttributes = array(Ess_M2ePro_Model_Magento_Product_Variation::GROUPED_PRODUCT_ATTRIBUTE_LABEL => $channelAttribute); return $this; } foreach ($this->getSourceAttributesData() as $magentoAttribute => $names) { $this->getResolver()->addSourceAttribute($magentoAttribute, $this->prepareAttributeNames($magentoAttribute, $names)); } foreach ($this->getDestinationAttributesData() as $channelAttribute => $names) { $this->getResolver()->addDestinationAttribute($channelAttribute, $this->prepareAttributeNames($channelAttribute, $names)); } $this->matchedAttributes = $this->getResolver()->resolve()->getResolvedAttributes(); return $this; }
private function match() { if (!is_null($this->magentoProduct) && $this->magentoProduct->isGroupedType() && !$this->magentoProduct->getVariationVirtualAttributes()) { $channelAttribute = reset($this->destinationAttributes); $this->matchedAttributes = array(Ess_M2ePro_Model_Magento_Product_Variation::GROUPED_PRODUCT_ATTRIBUTE_LABEL => $channelAttribute); return; } if ($this->matchByNames()) { return; } if (!$this->canUseDictionary) { return; } if ($this->matchByLocalVocabulary()) { return; } $this->matchByServerVocabulary(); }