/** * @param Ess_M2ePro_Model_Listing_Product $listingProduct * @return bool * @throws Ess_M2ePro_Model_Exception * @throws Ess_M2ePro_Model_Exception_Logic */ public function isMeetRelistRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct) { if (!$listingProduct->isStopped() || $listingProduct->isBlocked()) { return false; } if (!$listingProduct->isRelistable()) { return false; } /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */ $amazonListingProduct = $listingProduct->getChildObject(); $variationManager = $amazonListingProduct->getVariationManager(); if ($variationManager->isVariationProduct()) { if ($variationManager->isRelationParentType()) { return false; } if (!$variationManager->getTypeModel()->isVariationProductMatched()) { return false; } } $amazonSynchronizationTemplate = $amazonListingProduct->getAmazonSynchronizationTemplate(); if (!$amazonSynchronizationTemplate->isRelistMode()) { return false; } if ($amazonSynchronizationTemplate->isRelistFilterUserLock() && $listingProduct->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) { return false; } if ($listingProduct->isLockedObject('in_action')) { return false; } $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation'); if ($amazonSynchronizationTemplate->isRelistStatusEnabled()) { if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) { return false; } else { if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) { $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return false; } } } } if ($amazonSynchronizationTemplate->isRelistIsInStock()) { if (!$listingProduct->getMagentoProduct()->isStockAvailability()) { return false; } else { if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) { $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return false; } } } } if ($amazonSynchronizationTemplate->isRelistWhenQtyMagentoHasValue()) { $result = false; $productQty = (int) $amazonListingProduct->getQty(true); $typeQty = (int) $amazonSynchronizationTemplate->getRelistWhenQtyMagentoHasValueType(); $minQty = (int) $amazonSynchronizationTemplate->getRelistWhenQtyMagentoHasValueMin(); $maxQty = (int) $amazonSynchronizationTemplate->getRelistWhenQtyMagentoHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_QTY_LESS && $productQty <= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_QTY_MORE && $productQty >= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { $result = true; } if (!$result) { return false; } } if ($amazonSynchronizationTemplate->isRelistWhenQtyCalculatedHasValue()) { $result = false; $productQty = (int) $amazonListingProduct->getQty(false); $typeQty = (int) $amazonSynchronizationTemplate->getRelistWhenQtyCalculatedHasValueType(); $minQty = (int) $amazonSynchronizationTemplate->getRelistWhenQtyCalculatedHasValueMin(); $maxQty = (int) $amazonSynchronizationTemplate->getRelistWhenQtyCalculatedHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_QTY_LESS && $productQty <= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_QTY_MORE && $productQty >= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { $result = true; } if (!$result) { return false; } } return true; }
public function isMeetRelistRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct) { // Is checked before? //-------------------- if (in_array($listingProduct->getId(), $this->_checkedRelistListingsProductsIds)) { return false; } else { $this->_checkedRelistListingsProductsIds[] = $listingProduct->getId(); } //-------------------- // Amazon available status //-------------------- if (!$listingProduct->isStopped() || $listingProduct->isBlocked()) { return false; } if (!$listingProduct->isRelistable()) { return false; } if ($this->getRunner()->isExistProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_RELIST, array())) { 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->isRelistMode()) { return false; } if ($amazonSynchronizationTemplate->isRelistFilterUserLock() && $listingProduct->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) { return false; } if ($listingProduct->getChildObject()->isVariationProduct() && !$listingProduct->getChildObject()->isVariationMatched()) { return false; } //-------------------- $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation'); // Check filters //-------------------- if ($amazonSynchronizationTemplate->isRelistStatusEnabled()) { if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) { return false; } else { if ($listingProduct->getChildObject()->isVariationsReady()) { $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return false; } } } } if ($amazonSynchronizationTemplate->isRelistIsInStock()) { if (!$listingProduct->getMagentoProduct()->isStockAvailability()) { return false; } else { if ($listingProduct->getChildObject()->isVariationsReady()) { $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return false; } } } } if ($amazonSynchronizationTemplate->isRelistWhenQtyHasValue()) { $result = false; $productQty = (int) $listingProduct->getChildObject()->getQty(true); $typeQty = (int) $amazonSynchronizationTemplate->getRelistWhenQtyHasValueType(); $minQty = (int) $amazonSynchronizationTemplate->getRelistWhenQtyHasValueMin(); $maxQty = (int) $amazonSynchronizationTemplate->getRelistWhenQtyHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_QTY_LESS && $productQty <= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_QTY_MORE && $productQty >= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { $result = true; } if (!$result) { return false; } } //-------------------- return true; }
public function isMeetRelistRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct) { // Is checked before? //-------------------- if (in_array($listingProduct->getId(), $this->_checkedRelistListingsProductsIds)) { return false; } else { $this->_checkedRelistListingsProductsIds[] = $listingProduct->getId(); } //-------------------- // Play available status //-------------------- if (!$listingProduct->isStopped()) { return false; } if (!$listingProduct->isRelistable()) { return false; } if ($this->_runnerActions->isExistProductAction($listingProduct, Ess_M2ePro_Model_Connector_Server_Play_Product_Dispatcher::ACTION_RELIST, array())) { return false; } if ($listingProduct->isLockedObject(NULL) || $listingProduct->isLockedObject('in_action')) { return false; } //-------------------- // Correct synchronization //-------------------- if (!$listingProduct->getChildObject()->getPlaySynchronizationTemplate()->isRelistMode()) { return false; } if ($listingProduct->getChildObject()->getPlaySynchronizationTemplate()->isRelistFilterUserLock() && $listingProduct->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) { return false; } //-------------------- $productsIdsForEachVariation = NULL; // Check filters //-------------------- if ($listingProduct->getChildObject()->getPlaySynchronizationTemplate()->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) { $statusesTemp = $listingProduct->getVariationsStatuses($productsIdsForEachVariation); if ((int) min($statusesTemp) == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) { return false; } } } } if ($listingProduct->getChildObject()->getPlaySynchronizationTemplate()->isRelistIsInStock()) { if (!$listingProduct->getMagentoProduct()->getStockAvailability()) { return false; } else { if (is_null($productsIdsForEachVariation)) { $productsIdsForEachVariation = $listingProduct->getProductsIdsForEachVariation(); } if (count($productsIdsForEachVariation) > 0) { $stockAvailabilityTemp = $listingProduct->getVariationsStockAvailabilities($productsIdsForEachVariation); if (!(int) max($stockAvailabilityTemp)) { return false; } } } } if ($listingProduct->getChildObject()->getPlaySynchronizationTemplate()->isRelistWhenQtyHasValue()) { $result = false; $productQty = (int) $listingProduct->getChildObject()->getQty(true); $playSynchronizationTemplate = $listingProduct->getChildObject()->getPlaySynchronizationTemplate(); $typeQty = (int) $playSynchronizationTemplate->getRelistWhenQtyHasValueType(); $minQty = (int) $playSynchronizationTemplate->getRelistWhenQtyHasValueMin(); $maxQty = (int) $playSynchronizationTemplate->getRelistWhenQtyHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Play_Template_Synchronization::RELIST_QTY_LESS && $productQty <= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Play_Template_Synchronization::RELIST_QTY_MORE && $productQty >= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Play_Template_Synchronization::RELIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { $result = true; } if (!$result) { return false; } } //-------------------- return true; }
/** * @param Ess_M2ePro_Model_Listing_Product $listingProduct * @return bool * @throws Ess_M2ePro_Model_Exception_Logic */ public function isMeetRelistRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct) { if ($listingProduct->isListed()) { return false; } if (!$listingProduct->isRelistable() && !$listingProduct->isHidden()) { return false; } /** @var Ess_M2ePro_Model_Ebay_Listing_Product $ebayListingProduct */ $ebayListingProduct = $listingProduct->getChildObject(); $ebaySynchronizationTemplate = $ebayListingProduct->getEbaySynchronizationTemplate(); // Correct synchronization // --------------------------------------- if (!$ebaySynchronizationTemplate->isRelistMode()) { return false; } if ($listingProduct->isStopped() && $ebaySynchronizationTemplate->isRelistFilterUserLock() && $listingProduct->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) { return false; } if (!$ebayListingProduct->isSetCategoryTemplate()) { return false; } // --------------------------------------- $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation'); // Check filters // --------------------------------------- if ($ebaySynchronizationTemplate->isRelistStatusEnabled()) { if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) { return false; } else { if ($ebayListingProduct->isVariationsReady()) { $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return false; } } } } if ($ebaySynchronizationTemplate->isRelistIsInStock()) { if (!$listingProduct->getMagentoProduct()->isStockAvailability()) { return false; } else { if ($ebayListingProduct->isVariationsReady()) { $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return false; } } } } if ($ebaySynchronizationTemplate->isRelistWhenQtyMagentoHasValue()) { $result = false; $productQty = (int) $listingProduct->getMagentoProduct()->getQty(true); $typeQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyMagentoHasValueType(); $minQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyMagentoHasValueMin(); $maxQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyMagentoHasValueMax(); 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; } } if ($ebaySynchronizationTemplate->isRelistWhenQtyCalculatedHasValue()) { $result = false; $productQty = (int) $ebayListingProduct->getQty(); $typeQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyCalculatedHasValueType(); $minQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyCalculatedHasValueMin(); $maxQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyCalculatedHasValueMax(); 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; }