Esempio n. 1
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @return bool
  * @throws \Ess\M2ePro\Model\Exception\Logic
  */
 public function isMeetReviseGeneralRequirements(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     if (!$listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isRevisable() || $listingProduct->isHidden()) {
         return false;
     }
     /** @var \Ess\M2ePro\Model\Ebay\Listing\Product $ebayListingProduct */
     $ebayListingProduct = $listingProduct->getChildObject();
     if (!$ebayListingProduct->isSetCategoryTemplate()) {
         return false;
     }
     if ($listingProduct->isSetProcessingLock('in_action')) {
         return false;
     }
     return true;
 }
Esempio n. 2
0
 private function getAction(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     if ($listingProduct->isHidden()) {
         return \Ess\M2ePro\Model\Listing\Product::ACTION_REVISE;
     }
     return \Ess\M2ePro\Model\Listing\Product::ACTION_RELIST;
 }
Esempio n. 3
0
 protected function inspectProduct()
 {
     if (!$this->isSuccess && !$this->isSkipped) {
         return;
     }
     /** @var Runner $runner */
     $runner = $this->modelFactory->getObject('Synchronization\\Templates\\Synchronization\\Runner');
     $runner->setConnectorModel('Ebay\\Connector\\Item\\Dispatcher');
     $runner->setMaxProductsPerStep(100);
     /** @var Inspector $inspector */
     $inspector = $this->modelFactory->getObject('Ebay\\Synchronization\\Templates\\Synchronization\\Inspector');
     /** @var \Ess\M2ePro\Model\Ebay\Listing\Product $ebayListingProduct */
     $ebayListingProduct = $this->listingProduct->getChildObject();
     if ($this->listingProduct->isListed()) {
         /** @var Configurator $configurator */
         $configurator = $this->modelFactory->getObject('Ebay\\Listing\\Product\\Action\\Configurator');
         if ($inspector->isMeetStopRequirements($this->listingProduct)) {
             $action = \Ess\M2ePro\Model\Listing\Product::ACTION_STOP;
             if ($ebayListingProduct->isOutOfStockControlEnabled()) {
                 $action = \Ess\M2ePro\Model\Listing\Product::ACTION_REVISE;
                 $configurator->setParams(array('replaced_action' => \Ess\M2ePro\Model\Listing\Product::ACTION_STOP));
                 $configurator->setPartialMode();
                 $configurator->allowQty()->allowVariations();
             }
             $runner->addProduct($this->listingProduct, $action, $configurator);
             $runner->execute();
             return;
         }
         $configurator->setPartialMode();
         $needRevise = false;
         if ($inspector->isMeetReviseQtyRequirements($this->listingProduct)) {
             $configurator->allowQty();
             $needRevise = true;
         }
         if ($inspector->isMeetRevisePriceRequirements($this->listingProduct)) {
             $configurator->allowPrice();
             $needRevise = true;
         }
         if (!$needRevise) {
             return;
         }
         if ($ebayListingProduct->isVariationsReady()) {
             $configurator->allowVariations();
         }
         $runner->addProduct($this->listingProduct, \Ess\M2ePro\Model\Listing\Product::ACTION_REVISE, $configurator);
         $runner->execute();
         return;
     }
     if ($this->listingProduct->isStopped() || $this->listingProduct->isHidden()) {
         if (!$inspector->isMeetRelistRequirements($this->listingProduct)) {
             return;
         }
         /** @var Configurator $configurator */
         $configurator = $this->modelFactory->getObject('Ebay\\Listing\\Product\\Action\\Configurator');
         $action = \Ess\M2ePro\Model\Listing\Product::ACTION_RELIST;
         if ($this->listingProduct->isHidden()) {
             $configurator->setParams(array('replaced_action' => \Ess\M2ePro\Model\Listing\Product::ACTION_RELIST));
             $action = \Ess\M2ePro\Model\Listing\Product::ACTION_REVISE;
         }
         if (!$ebayListingProduct->getEbaySynchronizationTemplate()->isRelistSendData()) {
             $configurator->setPartialMode();
             $configurator->allowQty()->allowPrice()->allowVariations();
         }
         $runner->addProduct($this->listingProduct, $action, $configurator);
         $runner->execute();
     }
 }