Exemplo n.º 1
0
 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->getChildObject()->setData('variation_parent_need_processor', 0);
     $this->listingProduct->save();
 }
Exemplo n.º 2
0
 protected function canPerformGetItemCall()
 {
     if ($this->getStatusChanger() == \Ess\M2ePro\Model\Listing\Product::STATUS_CHANGER_USER) {
         return true;
     }
     $getItemCallsCount = 0;
     $getItemLastCallDate = NULL;
     $maxAllowedGetItemCallsCount = 2;
     $additionalData = $this->listingProduct->getAdditionalData();
     if (!empty($additionalData['get_item_calls_statistic'])) {
         $getItemCallsCount = $additionalData['get_item_calls_statistic']['count'];
         $getItemLastCallDate = $additionalData['get_item_calls_statistic']['last_call_date'];
     }
     if ($getItemCallsCount >= $maxAllowedGetItemCallsCount) {
         $minAllowedDate = new \DateTime('now', new \DateTimeZone('UTC'));
         $minAllowedDate->modify('- 1 day');
         if (strtotime($getItemLastCallDate) > $minAllowedDate->format('U')) {
             return false;
         }
         $getItemCallsCount = 0;
     }
     $getItemCallsCount++;
     $getItemLastCallDate = $this->helperFactory->getObject('Data')->getCurrentGmtDate();
     $additionalData['get_item_calls_statistic']['count'] = $getItemCallsCount;
     $additionalData['get_item_calls_statistic']['last_call_date'] = $getItemLastCallDate;
     $this->listingProduct->setSettings('additional_data', $additionalData);
     $this->listingProduct->save();
     return true;
 }
Exemplo n.º 3
0
 protected function processAddedListingProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct, array $params)
 {
     $ebayListingProduct = $listingProduct->getChildObject();
     if (!empty($params['template_category_id'])) {
         $ebayListingProduct->setData('template_category_id', $params['template_category_id']);
     }
     if (!empty($params['template_other_category_id'])) {
         $ebayListingProduct->setData('template_other_category_id', $params['template_other_category_id']);
     }
     $listingProduct->save();
 }
Exemplo n.º 4
0
 private function setListAttemptData(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     $additionalData = $listingProduct->getAdditionalData();
     $additionalData['last_list_attempt_date'] = $this->getHelper('Data')->getCurrentGmtDate();
     $listingProduct->setSettings('additional_data', $additionalData);
     $listingProduct->save();
 }
Exemplo n.º 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\ChildRelation $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()->tryToRemoveChildListingProduct($existChild);
         }
         $productVariation = $this->getProcessor()->getProductVariation($productOption);
         if (empty($productVariation)) {
             continue;
         }
         $typeModel->setProductVariation($productVariation);
         $listingProduct->save();
         break;
     }
 }
Exemplo n.º 6
0
 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()) {
         $amazonListingProduct->setData('template_description_id', $params['template_description_id']);
         $amazonListingProduct->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 = $this->modelFactory->getObject('Amazon\\Marketplace\\Details');
     $detailsModel->setMarketplaceId($listingProduct->getListing()->getMarketplaceId());
     /** @var \Ess\M2ePro\Model\Template\Description $descriptionTemplate */
     $descriptionTemplate = $this->amazonFactory->getObjectLoaded('Template\\Description', $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;
         }
         $amazonListingProduct->setData('template_description_id', $params['template_description_id']);
         $amazonListingProduct->setData('is_general_id_owner', \Ess\M2ePro\Model\Amazon\Listing\Product::IS_GENERAL_ID_OWNER_YES);
         break;
     }
     $listingProduct->save();
     $processor->process();
 }