Ejemplo n.º 1
0
 /**
  * @param Ess_M2ePro_Model_Listing_Product $listingProduct
  * @return bool
  * @throws Ess_M2ePro_Model_Exception
  * @throws Ess_M2ePro_Model_Exception_Logic
  */
 public function isMeetReviseGeneralRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     if (!$amazonListingProduct->isAfnChannel() && (!$listingProduct->isListed() || $listingProduct->isBlocked())) {
         return false;
     }
     if (!$listingProduct->isRevisable()) {
         return false;
     }
     $variationManager = $amazonListingProduct->getVariationManager();
     if ($variationManager->isVariationProduct()) {
         if ($variationManager->isRelationParentType()) {
             return false;
         }
         if ($variationManager->isPhysicalUnit() && !$variationManager->getTypeModel()->isVariationProductMatched()) {
             return false;
         }
     }
     if ($listingProduct->isLockedObject('in_action')) {
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 public function inspectRevisePriceRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedPriceListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedPriceListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // Prepare actions params
     //--------------------
     $actionParams = array('only_data' => array('price' => true));
     //--------------------
     // Amazon available status
     //--------------------
     if (!$listingProduct->isListed() || $listingProduct->isBlocked()) {
         return false;
     }
     if (!$listingProduct->isRevisable()) {
         return false;
     }
     if ($this->getRunner()->isExistProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams)) {
         return false;
     }
     if ($listingProduct->isLockedObject(NULL) || $listingProduct->isLockedObject('in_action')) {
         return false;
     }
     //--------------------
     /* @var $amazonSynchronizationTemplate Ess_M2ePro_Model_Amazon_Template_Synchronization */
     $amazonSynchronizationTemplate = $listingProduct->getChildObject()->getAmazonSynchronizationTemplate();
     // Correct synchronization
     //--------------------
     if (!$amazonSynchronizationTemplate->isReviseWhenChangePrice()) {
         return false;
     }
     if ($listingProduct->getChildObject()->isVariationProduct() && !$listingProduct->getChildObject()->isVariationMatched()) {
         return false;
     }
     //--------------------
     // Check filters
     //--------------------
     $currentPrice = $listingProduct->getChildObject()->getPrice();
     $onlinePrice = $listingProduct->getChildObject()->getOnlinePrice();
     if ($currentPrice != $onlinePrice) {
         $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams);
         return true;
     }
     $currentSalePriceInfo = $listingProduct->getChildObject()->getSalePriceInfo();
     $currentSalePrice = $currentSalePriceInfo['price'];
     $onlineSalePrice = $listingProduct->getChildObject()->getOnlineSalePrice();
     if (is_null($currentSalePrice) && !is_null($onlineSalePrice) || !is_null($currentSalePrice) && is_null($onlineSalePrice) || (double) $currentSalePrice != (double) $onlineSalePrice) {
         $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams);
         return true;
     }
     //--------------------
     //--------------------
     $currentSalePriceStartDate = $currentSalePriceInfo['start_date'];
     $onlineSalePriceStartDate = $listingProduct->getChildObject()->getOnlineSalePriceStartDate();
     $currentSalePriceEndDate = $currentSalePriceInfo['end_date'];
     $onlineSalePriceEndDate = $listingProduct->getChildObject()->getOnlineSalePriceEndDate();
     if ($currentSalePriceStartDate != $onlineSalePriceStartDate || $currentSalePriceEndDate != $onlineSalePriceEndDate) {
         $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams);
         return true;
     }
     //--------------------
     return false;
 }
Ejemplo n.º 3
0
 public function inspectRevisePriceRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedPriceListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedPriceListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // Prepare actions params
     //--------------------
     $actionParams = array('only_data' => array('price' => true));
     //--------------------
     // Play available status
     //--------------------
     if (!$listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isRevisable()) {
         return false;
     }
     if ($this->_runnerActions->isExistProductAction($listingProduct, Ess_M2ePro_Model_Connector_Server_Play_Product_Dispatcher::ACTION_REVISE, $actionParams)) {
         return false;
     }
     if ($listingProduct->isLockedObject(NULL) || $listingProduct->isLockedObject('in_action')) {
         return false;
     }
     //--------------------
     // Correct synchronization
     //--------------------
     if (!$listingProduct->getChildObject()->getPlaySynchronizationTemplate()->isReviseWhenChangePrice()) {
         return false;
     }
     //--------------------
     // Check filters
     //--------------------
     $onlinePriceGbr = $listingProduct->getChildObject()->getOnlinePriceGbr();
     $currentPriceGbr = $listingProduct->getChildObject()->getPriceGbr(true);
     if ($currentPriceGbr != $onlinePriceGbr) {
         $this->_runnerActions->setProduct($listingProduct, Ess_M2ePro_Model_Connector_Server_Play_Product_Dispatcher::ACTION_REVISE, $actionParams);
         return true;
     }
     $onlinePriceEuro = $listingProduct->getChildObject()->getOnlinePriceEuro();
     $currentPriceEuro = $listingProduct->getChildObject()->getPriceEuro(true);
     if ($onlinePriceEuro != $currentPriceEuro) {
         $this->_runnerActions->setProduct($listingProduct, Ess_M2ePro_Model_Connector_Server_Play_Product_Dispatcher::ACTION_REVISE, $actionParams);
         return true;
     }
     //--------------------
     return false;
 }
 /**
  * @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;
     }
     return true;
 }
Ejemplo n.º 5
0
 private function inspectRevisePriceRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedPriceListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedPriceListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // Prepare actions params
     //--------------------
     $actionParams = array('only_data' => array('price' => true, 'variations' => true));
     //--------------------
     // eBay available status
     //--------------------
     if (!$listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isRevisable()) {
         return false;
     }
     if ($this->_runnerActions->isExistProductAction($listingProduct, Ess_M2ePro_Model_Connector_Ebay_Item_Dispatcher::ACTION_REVISE, $actionParams)) {
         return false;
     }
     //--------------------
     // Correct synchronization
     //--------------------
     if (!$listingProduct->getChildObject()->isSetCategoryTemplate()) {
         return false;
     }
     if (!$listingProduct->getChildObject()->getEbaySynchronizationTemplate()->isReviseWhenChangePrice()) {
         return false;
     }
     //--------------------
     // Check filters
     //--------------------
     $isVariationProduct = $listingProduct->getChildObject()->isVariationMode() && count($listingProduct->getVariations()) > 0;
     if (!$isVariationProduct) {
         $hasChange = false;
         //---------
         $currentPrice = $listingProduct->getChildObject()->getBuyItNowPrice();
         $onlinePrice = $listingProduct->getChildObject()->getOnlineBuyItNowPrice();
         if ($currentPrice != $onlinePrice) {
             $hasChange = true;
         }
         if ($hasChange) {
             $this->_runnerActions->setProduct($listingProduct, Ess_M2ePro_Model_Connector_Ebay_Item_Dispatcher::ACTION_REVISE, $actionParams);
             return true;
         }
         //---------
         if ($listingProduct->getChildObject()->isListingTypeAuction()) {
             //---------
             $currentPrice = $listingProduct->getChildObject()->getStartPrice();
             $onlinePrice = $listingProduct->getChildObject()->getOnlineStartPrice();
             if ($currentPrice != $onlinePrice) {
                 $hasChange = true;
             }
             if ($hasChange) {
                 $this->_runnerActions->setProduct($listingProduct, Ess_M2ePro_Model_Connector_Ebay_Item_Dispatcher::ACTION_REVISE, $actionParams);
                 return true;
             }
             //---------
             $currentPrice = $listingProduct->getChildObject()->getReservePrice();
             $onlinePrice = $listingProduct->getChildObject()->getOnlineReservePrice();
             if ($currentPrice != $onlinePrice) {
                 $hasChange = true;
             }
             if ($hasChange) {
                 $this->_runnerActions->setProduct($listingProduct, Ess_M2ePro_Model_Connector_Ebay_Item_Dispatcher::ACTION_REVISE, $actionParams);
                 return true;
             }
             //---------
         }
     } else {
         $variations = $listingProduct->getVariations(true);
         foreach ($variations as $variation) {
             $currentPrice = $variation->getChildObject()->getPrice();
             $onlinePrice = $variation->getChildObject()->getOnlinePrice();
             if ($currentPrice != $onlinePrice) {
                 $this->_runnerActions->setProduct($listingProduct, Ess_M2ePro_Model_Connector_Ebay_Item_Dispatcher::ACTION_REVISE, $actionParams);
                 return true;
             }
         }
     }
     //--------------------
     return false;
 }
Ejemplo n.º 6
0
 public function isMeetReviseGeneralRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     if (!$listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isRevisable()) {
         return false;
     }
     if ($listingProduct->isLockedObject('in_action')) {
         return false;
     }
     /** @var Ess_M2ePro_Model_Buy_Listing_Product $buyListingProduct */
     $buyListingProduct = $listingProduct->getChildObject();
     $variationManager = $buyListingProduct->getVariationManager();
     if ($variationManager->isVariationProduct() && !$variationManager->isVariationProductMatched()) {
         return false;
     }
     return true;
 }
Ejemplo n.º 7
0
 private function isMeetRelistRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // eBay available status
     //--------------------
     if ($listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isRelistable()) {
         return false;
     }
     if ($this->_runnerActions->isExistProductAction($listingProduct, Ess_M2ePro_Model_Connector_Server_Ebay_Item_Dispatcher::ACTION_RELIST, array())) {
         return false;
     }
     //--------------------
     // Correct synchronization
     //--------------------
     if (!$listingProduct->getListing()->isSynchronizationNowRun()) {
         return false;
     }
     if (!$listingProduct->getSynchronizationTemplate()->getChildObject()->isRelistMode()) {
         return false;
     }
     if ($listingProduct->getSynchronizationTemplate()->getChildObject()->isRelistFilterUserLock() && $listingProduct->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) {
         return false;
     }
     //--------------------
     $uniqueOptionsProductsIds = NULL;
     // Check filters
     //--------------------
     if ($listingProduct->getSynchronizationTemplate()->getChildObject()->isRelistStatusEnabled()) {
         if ($listingProduct->getMagentoProduct()->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
             return false;
         } else {
             if (is_null($uniqueOptionsProductsIds)) {
                 $uniqueOptionsProductsIds = $listingProduct->getUniqueOptionsProductsIds();
             }
             if (count($uniqueOptionsProductsIds) > 0) {
                 $statusesTemp = $listingProduct->getUniqueOptionsProductsStatuses($uniqueOptionsProductsIds);
                 if ((int) min($statusesTemp) == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
                     return false;
                 }
             }
         }
     }
     if ($listingProduct->getSynchronizationTemplate()->getChildObject()->isRelistIsInStock()) {
         if (!$listingProduct->getMagentoProduct()->getStockAvailability()) {
             return false;
         } else {
             if (is_null($uniqueOptionsProductsIds)) {
                 $uniqueOptionsProductsIds = $listingProduct->getUniqueOptionsProductsIds();
             }
             if (count($uniqueOptionsProductsIds) > 0) {
                 $stockAvailabilityTemp = $listingProduct->getUniqueOptionsProductsStockAvailability($uniqueOptionsProductsIds);
                 if (!(int) max($stockAvailabilityTemp)) {
                     return false;
                 }
             }
         }
     }
     if ($listingProduct->getSynchronizationTemplate()->getChildObject()->isRelistWhenQtyHasValue()) {
         $result = false;
         $productQty = (int) $listingProduct->getChildObject()->getQty(true);
         $ebaySynchronizationTemplate = $listingProduct->getSynchronizationTemplate()->getChildObject();
         $typeQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::RELIST_QTY_LESS && $productQty <= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::RELIST_QTY_MORE && $productQty >= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::RELIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             $result = true;
         }
         if (!$result) {
             return false;
         }
     }
     //--------------------
     return true;
 }
Ejemplo n.º 8
0
 private function isMeetStopRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // eBay available status
     //--------------------
     if (!$listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isStoppable() || $listingProduct->isHidden()) {
         return false;
     }
     $tempActionAndParams = $this->getActionAndParamsFromListingProduct($listingProduct);
     if ($this->_runnerActions->isExistProductAction($listingProduct, $tempActionAndParams['action'], $tempActionAndParams['params'])) {
         return false;
     }
     //--------------------
     $productsIdsForEachVariation = NULL;
     // Check filters
     //--------------------
     if ($listingProduct->getChildObject()->getEbaySynchronizationTemplate()->isStopStatusDisabled()) {
         if ($listingProduct->getMagentoProduct()->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
             return true;
         } else {
             if (is_null($productsIdsForEachVariation)) {
                 $productsIdsForEachVariation = $listingProduct->getProductsIdsForEachVariation();
             }
             if (count($productsIdsForEachVariation) > 0) {
                 $tempStatuses = $listingProduct->getVariationsStatuses($productsIdsForEachVariation);
                 // all variations are disabled
                 if ((int) min($tempStatuses) == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
                     return true;
                 }
             }
         }
     }
     if ($listingProduct->getChildObject()->getEbaySynchronizationTemplate()->isStopOutOfStock()) {
         if (!$listingProduct->getMagentoProduct()->getStockAvailability()) {
             return true;
         } else {
             if (is_null($productsIdsForEachVariation)) {
                 $productsIdsForEachVariation = $listingProduct->getProductsIdsForEachVariation();
             }
             if (count($productsIdsForEachVariation) > 0) {
                 $tempStocks = $listingProduct->getVariationsStockAvailabilities($productsIdsForEachVariation);
                 // all variations are out of stock
                 if (!(int) max($tempStocks)) {
                     return true;
                 }
             }
         }
     }
     if ($listingProduct->getChildObject()->getEbaySynchronizationTemplate()->isStopWhenQtyHasValue()) {
         $productQty = (int) $listingProduct->getChildObject()->getQtyTotal(true);
         $ebaySynchronizationTemplate = $listingProduct->getChildObject()->getEbaySynchronizationTemplate();
         $typeQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             return true;
         }
     }
     //--------------------
     return false;
 }
Ejemplo n.º 9
0
 public function inspectRevisePriceRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->checkedPriceListingsProductsIds)) {
         return false;
     } else {
         $this->checkedPriceListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // Prepare actions params
     //--------------------
     $actionParams = array('only_data' => array('price' => true, 'variations' => true));
     //--------------------
     // eBay available status
     //--------------------
     if (!$listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isRevisable()) {
         return false;
     }
     if ($this->getRunner()->isExistProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams)) {
         return false;
     }
     if ($listingProduct->isLockedObject(NULL) || $listingProduct->isLockedObject('in_action')) {
         return false;
     }
     //--------------------
     /* @var $ebaySynchronizationTemplate Ess_M2ePro_Model_Ebay_Template_Synchronization */
     $ebaySynchronizationTemplate = $listingProduct->getChildObject()->getEbaySynchronizationTemplate();
     // Correct synchronization
     //--------------------
     if (!$ebaySynchronizationTemplate->isReviseWhenChangePrice()) {
         return false;
     }
     if (!$listingProduct->getChildObject()->isSetCategoryTemplate()) {
         return false;
     }
     //--------------------
     // Check filters
     //--------------------
     if (!$listingProduct->getChildObject()->isVariationsReady()) {
         $hasChange = false;
         //---------
         $currentPrice = $listingProduct->getChildObject()->getBuyItNowPrice();
         $onlinePrice = $listingProduct->getChildObject()->getOnlineBuyItNowPrice();
         if ($currentPrice != $onlinePrice) {
             $hasChange = true;
         }
         if ($hasChange) {
             $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams);
             return true;
         }
         //---------
         if ($listingProduct->getChildObject()->isListingTypeAuction()) {
             //---------
             $currentPrice = $listingProduct->getChildObject()->getStartPrice();
             $onlinePrice = $listingProduct->getChildObject()->getOnlineStartPrice();
             if ($currentPrice != $onlinePrice) {
                 $hasChange = true;
             }
             if ($hasChange) {
                 $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams);
                 return true;
             }
             //---------
             $currentPrice = $listingProduct->getChildObject()->getReservePrice();
             $onlinePrice = $listingProduct->getChildObject()->getOnlineReservePrice();
             if ($currentPrice != $onlinePrice) {
                 $hasChange = true;
             }
             if ($hasChange) {
                 $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams);
                 return true;
             }
             //---------
         }
     } else {
         $variations = $listingProduct->getVariations(true);
         foreach ($variations as $variation) {
             $currentPrice = $variation->getChildObject()->getPrice();
             $onlinePrice = $variation->getChildObject()->getOnlinePrice();
             if ($currentPrice != $onlinePrice) {
                 $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams);
                 return true;
             }
         }
     }
     //--------------------
     return false;
 }
Ejemplo n.º 10
0
 public function inspectRevisePriceRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedPriceListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedPriceListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // Prepare actions params
     //--------------------
     $actionParams = array('only_data' => array('price' => true));
     //--------------------
     // Buy available status
     //--------------------
     if (!$listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isRevisable()) {
         return false;
     }
     if ($this->getRunner()->isExistProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams)) {
         return false;
     }
     if ($listingProduct->isLockedObject(NULL) || $listingProduct->isLockedObject('in_action')) {
         return false;
     }
     //--------------------
     /* @var $buySynchronizationTemplate Ess_M2ePro_Model_Buy_Template_Synchronization */
     $buySynchronizationTemplate = $listingProduct->getChildObject()->getBuySynchronizationTemplate();
     // Correct synchronization
     //--------------------
     if (!$buySynchronizationTemplate->isReviseWhenChangePrice()) {
         return false;
     }
     if ($listingProduct->getChildObject()->isVariationProduct() && !$listingProduct->getChildObject()->isVariationMatched()) {
         return false;
     }
     //--------------------
     // Check filters
     //--------------------
     $currentPrice = $listingProduct->getChildObject()->getPrice();
     $onlinePrice = $listingProduct->getChildObject()->getOnlinePrice();
     if ($currentPrice != $onlinePrice) {
         $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams);
         return true;
     }
     //--------------------
     return false;
 }
Ejemplo n.º 11
0
 private function isMeetRelistRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // eBay available status
     //--------------------
     if ($listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isRelistable() && !$listingProduct->isHidden()) {
         return false;
     }
     $tempActionAndParams = $this->getActionAndParamsFromListingProduct($listingProduct);
     if ($this->_runnerActions->isExistProductAction($listingProduct, $tempActionAndParams['action'], $listingProduct->isHidden() ? $tempActionAndParams['params'] : array())) {
         return false;
     }
     //--------------------
     /* @var $ebaySynchronizationTemplate Ess_M2ePro_Model_Ebay_Template_Synchronization */
     $ebaySynchronizationTemplate = $listingProduct->getChildObject()->getEbaySynchronizationTemplate();
     // Correct synchronization
     //--------------------
     if (!$listingProduct->getChildObject()->isSetCategoryTemplate()) {
         return false;
     }
     if (!$ebaySynchronizationTemplate->isRelistMode()) {
         return false;
     }
     if ($ebaySynchronizationTemplate->isRelistFilterUserLock() && $listingProduct->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) {
         return false;
     }
     if ($ebaySynchronizationTemplate->isScheduleEnabled()) {
         if (!$ebaySynchronizationTemplate->isScheduleIntervalNow() || !$ebaySynchronizationTemplate->isScheduleWeekNow()) {
             return false;
         }
     }
     //--------------------
     $productsIdsForEachVariation = NULL;
     // Check filters
     //--------------------
     if ($ebaySynchronizationTemplate->isRelistStatusEnabled()) {
         if ($listingProduct->getMagentoProduct()->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
             return false;
         } else {
             if (is_null($productsIdsForEachVariation)) {
                 $productsIdsForEachVariation = $listingProduct->getProductsIdsForEachVariation();
             }
             if (count($productsIdsForEachVariation) > 0) {
                 $tempStatuses = $listingProduct->getVariationsStatuses($productsIdsForEachVariation);
                 // all variations are disabled
                 if ((int) min($tempStatuses) == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
                     return false;
                 }
             }
         }
     }
     if ($ebaySynchronizationTemplate->isRelistIsInStock()) {
         if (!$listingProduct->getMagentoProduct()->getStockAvailability()) {
             return false;
         } else {
             if (is_null($productsIdsForEachVariation)) {
                 $productsIdsForEachVariation = $listingProduct->getProductsIdsForEachVariation();
             }
             if (count($productsIdsForEachVariation) > 0) {
                 $tempStocks = $listingProduct->getVariationsStockAvailabilities($productsIdsForEachVariation);
                 // all variations are out of stock
                 if (!(int) max($tempStocks)) {
                     return false;
                 }
             }
         }
     }
     if ($ebaySynchronizationTemplate->isRelistWhenQtyHasValue()) {
         $result = false;
         $productQty = (int) $listingProduct->getChildObject()->getQtyTotal(true);
         $typeQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::RELIST_QTY_LESS && $productQty <= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::RELIST_QTY_MORE && $productQty >= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::RELIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             $result = true;
         }
         if (!$result) {
             return false;
         }
     }
     //--------------------
     return true;
 }
Ejemplo n.º 12
0
 public function inspectRevisePriceRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedPriceListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedPriceListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // Prepare actions params
     //--------------------
     $actionParams = array('only_data' => array('price' => true, 'variations' => true));
     //--------------------
     // Amazon available status
     //--------------------
     if (!$listingProduct->isListed() || $listingProduct->isBlocked()) {
         return false;
     }
     if (!$listingProduct->isRevisable()) {
         return false;
     }
     if ($this->_runnerActions->isExistProductAction($listingProduct, Ess_M2ePro_Model_Amazon_Connector_Product_Dispatcher::ACTION_REVISE, $actionParams)) {
         return false;
     }
     if ($listingProduct->isLockedObject(NULL) || $listingProduct->isLockedObject('in_action')) {
         return false;
     }
     //--------------------
     // Correct synchronization
     //--------------------
     if (!$listingProduct->getListing()->isSynchronizationNowRun()) {
         return false;
     }
     if (!$listingProduct->getSynchronizationTemplate()->getChildObject()->isReviseWhenChangePrice()) {
         return false;
     }
     //--------------------
     // Check filters
     //--------------------
     $isVariationProduct = $listingProduct->getMagentoProduct()->isProductWithVariations() && (bool) count($listingProduct->getVariations());
     if (!$isVariationProduct) {
         $currentPrice = $listingProduct->getChildObject()->getPrice();
         $onlinePrice = $listingProduct->getChildObject()->getOnlinePrice();
         if ($currentPrice != $onlinePrice) {
             $this->_runnerActions->setProduct($listingProduct, Ess_M2ePro_Model_Amazon_Connector_Product_Dispatcher::ACTION_REVISE, $actionParams);
             return true;
         }
         $currentSalePrice = $listingProduct->getChildObject()->getSalePrice();
         $onlineSalePrice = $listingProduct->getChildObject()->getOnlineSalePrice();
         if (is_null($currentSalePrice) && !is_null($onlineSalePrice) || !is_null($currentSalePrice) && is_null($onlineSalePrice) || (double) $currentSalePrice != (double) $onlineSalePrice) {
             $this->_runnerActions->setProduct($listingProduct, Ess_M2ePro_Model_Amazon_Connector_Product_Dispatcher::ACTION_REVISE, $actionParams);
             return true;
         }
     } else {
         $variations = $listingProduct->getVariations(true);
         foreach ($variations as $variation) {
             $currentPrice = $variation->getChildObject()->getPrice();
             $onlinePrice = $variation->getChildObject()->getOnlinePrice();
             if ($currentPrice != $onlinePrice) {
                 $this->_runnerActions->setProduct($listingProduct, Ess_M2ePro_Model_Amazon_Connector_Product_Dispatcher::ACTION_REVISE, $actionParams);
                 return true;
             }
         }
     }
     //--------------------
     return false;
 }