Exemplo n.º 1
0
 private function executeUpdateInventoryDataAccount(\Ess\M2ePro\Model\Account $account)
 {
     $sinceTime = $account->getData('other_listings_last_synchronization');
     if (empty($sinceTime)) {
         $marketplaceCollection = $this->ebayFactory->getObject('Marketplace')->getCollection();
         $marketplaceCollection->addFieldToFilter('status', \Ess\M2ePro\Model\Marketplace::STATUS_ENABLE);
         $marketplace = $marketplaceCollection->getFirstItem();
         if (!$marketplace->getId()) {
             $marketplace = \Ess\M2ePro\Helper\Component\Ebay::MARKETPLACE_US;
         } else {
             $marketplace = $marketplace->getId();
         }
         $dispatcherObject = $this->modelFactory->getObject('Ebay\\Connector\\Dispatcher');
         $connectorObj = $dispatcherObject->getCustomConnector('Ebay\\Synchronization\\OtherListings\\Update\\Requester', array(), $marketplace, $account->getId());
         $dispatcherObject->process($connectorObj);
         return;
     }
     $sinceTime = $this->prepareSinceTime($sinceTime);
     $changes = $this->getChangesByAccount($account, $sinceTime);
     /** @var $updatingModel \Ess\M2ePro\Model\Ebay\Listing\Other\Updating */
     $updatingModel = $this->modelFactory->getObject('Ebay\\Listing\\Other\\Updating');
     $updatingModel->initialize($account);
     $updatingModel->processResponseData($changes);
 }
Exemplo n.º 2
0
 private function processAccount(\Ess\M2ePro\Model\Account $account)
 {
     $sinceTime = $this->prepareSinceTime($account->getData('defaults_last_synchronization'));
     $changesByAccount = $this->getChangesByAccount($account, $sinceTime);
     if (!isset($changesByAccount['items']) || !isset($changesByAccount['to_time'])) {
         return;
     }
     $account->getChildObject()->setData('defaults_last_synchronization', $changesByAccount['to_time'])->save();
     $this->getHelper('Data\\Cache\\Session')->setValue('item_get_changes_data_' . $account->getId(), $changesByAccount);
     foreach ($changesByAccount['items'] as $change) {
         /* @var $listingProduct \Ess\M2ePro\Model\Listing\Product */
         $listingProduct = $this->getHelper('Component\\Ebay')->getListingProductByEbayItem($change['id'], $account->getId());
         if (is_null($listingProduct)) {
             continue;
         }
         // Listing product isn't listed and it child must have another item_id
         if ($listingProduct->getStatus() != \Ess\M2ePro\Model\Listing\Product::STATUS_LISTED && $listingProduct->getStatus() != \Ess\M2ePro\Model\Listing\Product::STATUS_HIDDEN) {
             continue;
         }
         $this->listingsProductsLockStatus[$listingProduct->getId()] = $listingProduct->isSetProcessingLock('in_action');
         $this->processListingProduct($listingProduct, $change);
         if (empty($change['variations'])) {
             continue;
         }
         $variations = $listingProduct->getVariations(true);
         if (count($variations) <= 0) {
             continue;
         }
         $variationsSnapshot = $this->getVariationsSnapshot($variations);
         if (count($variationsSnapshot) <= 0) {
             return;
         }
         $this->processListingProductVariation($variationsSnapshot, $change['variations'], $listingProduct);
     }
 }