public function process()
 {
     if (is_null($this->listingProduct)) {
         throw new Ess_M2ePro_Model_Exception('Listing Product was not set.');
     }
     $this->getTypeModel()->enableCache();
     foreach ($this->getSortedProcessors() as $processor) {
         $this->getProcessorModel($processor)->process();
     }
     $this->listingProduct->setData('variation_parent_need_processor', 0);
     $this->listingProduct->save();
 }
 private function setListAttemptData(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $additionalData = $listingProduct->getAdditionalData();
     $additionalData['last_list_attempt_date'] = Mage::helper('M2ePro')->getCurrentGmtDate();
     $listingProduct->setSettings('additional_data', $additionalData);
     $listingProduct->save();
 }
 protected function processAddedListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct, array $params)
 {
     if (!empty($params['template_category_id'])) {
         $listingProduct->setData('template_category_id', $params['template_category_id']);
     }
     if (!empty($params['template_other_category_id'])) {
         $listingProduct->setData('template_other_category_id', $params['template_other_category_id']);
     }
     $listingProduct->save();
 }
 protected function processAddedListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct, array $params)
 {
     if (empty($params['template_description_id'])) {
         return;
     }
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     if (!$amazonListingProduct->getVariationManager()->isRelationParentType()) {
         $listingProduct->setData('template_description_id', $params['template_description_id']);
         $listingProduct->setData('is_general_id_owner', Ess_M2ePro_Model_Amazon_Listing_Product::IS_GENERAL_ID_OWNER_YES);
         $listingProduct->save();
         return;
     }
     $processor = $amazonListingProduct->getVariationManager()->getTypeModel()->getProcessor();
     if ($listingProduct->getMagentoProduct()->isBundleType() || $listingProduct->getMagentoProduct()->isSimpleTypeWithCustomOptions()) {
         $processor->process();
         return;
     }
     $detailsModel = Mage::getModel('M2ePro/Amazon_Marketplace_Details');
     $detailsModel->setMarketplaceId($listingProduct->getListing()->getMarketplaceId());
     /** @var Ess_M2ePro_Model_Template_Description $descriptionTemplate */
     $descriptionTemplate = Mage::helper('M2ePro/Component_Amazon')->getModel('Template_Description')->load($params['template_description_id']);
     /** @var Ess_M2ePro_Model_Amazon_Template_Description $amazonDescriptionTemplate */
     $amazonDescriptionTemplate = $descriptionTemplate->getChildObject();
     $possibleThemes = $detailsModel->getVariationThemes($amazonDescriptionTemplate->getProductDataNick());
     $productAttributes = $amazonListingProduct->getVariationManager()->getTypeModel()->getProductAttributes();
     foreach ($possibleThemes as $theme) {
         if (count($theme['attributes']) != count($productAttributes)) {
             continue;
         }
         $listingProduct->setData('template_description_id', $params['template_description_id']);
         $listingProduct->setData('is_general_id_owner', Ess_M2ePro_Model_Amazon_Listing_Product::IS_GENERAL_ID_OWNER_YES);
         break;
     }
     $listingProduct->save();
     $processor->process();
 }
Beispiel #5
0
 private function matchEmptyProductOptionsChild(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $typeModel */
     $typeModel = $amazonListingProduct->getVariationManager()->getTypeModel();
     $channelOptions = $typeModel->getChannelOptions();
     $productOptions = array_merge($this->getProcessor()->getTypeModel()->getNotRemovedUnusedProductOptions(), $this->getProcessor()->getTypeModel()->getUsedProductOptions(true));
     $matcher = $this->getOptionMatcher();
     $matcher->setDestinationOptions(array($amazonListingProduct->getGeneralId() => $channelOptions));
     foreach ($productOptions as $productOption) {
         $generalId = $matcher->getMatchedOptionGeneralId($productOption);
         if (is_null($generalId)) {
             continue;
         }
         $existChild = $this->findChildByProductOptions($productOption);
         if (!is_null($existChild)) {
             $this->getProcessor()->tryToDeleteChildListingProduct($existChild);
         }
         $productVariation = $this->getProcessor()->getProductVariation($productOption);
         if (empty($productVariation)) {
             continue;
         }
         $typeModel->setProductVariation($productVariation);
         $listingProduct->save();
         break;
     }
 }