public function add(Ess_M2ePro_Model_Listing_Product $listingProduct) { if (!$listingProduct->isStoppable()) { return false; } $itemData = $this->getItemDataByListingProduct($listingProduct); if (is_null($itemData)) { return false; } $marketplaceNativeId = $listingProduct->isComponentModeEbay() ? $listingProduct->getMarketplace()->getNativeId() : NULL; $addedData = array('item_data' => json_encode($itemData), 'account_hash' => $listingProduct->getAccount()->getChildObject()->getServerHash(), 'marketplace_id' => $marketplaceNativeId, 'component_mode' => $listingProduct->getComponentMode(), 'is_processed' => 0); Mage::getModel('M2ePro/StopQueue')->setData($addedData)->save(); return true; }
/** * @param Ess_M2ePro_Model_Listing_Product $listingProduct * @return bool * @throws Ess_M2ePro_Model_Exception * @throws Ess_M2ePro_Model_Exception_Logic */ public function isMeetStopRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct) { if (!$listingProduct->isListed() || $listingProduct->isBlocked()) { return false; } if (!$listingProduct->isStoppable()) { 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 ($listingProduct->isLockedObject('in_action')) { return false; } $amazonSynchronizationTemplate = $amazonListingProduct->getAmazonSynchronizationTemplate(); $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation'); if ($amazonSynchronizationTemplate->isStopStatusDisabled()) { if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) { return true; } else { if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) { $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return true; } } } } if ($amazonSynchronizationTemplate->isStopOutOfStock()) { if (!$listingProduct->getMagentoProduct()->isStockAvailability()) { return true; } else { if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) { $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return true; } } } } if ($amazonSynchronizationTemplate->isStopWhenQtyMagentoHasValue()) { $productQty = (int) $amazonListingProduct->getQty(true); $typeQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyMagentoHasValueType(); $minQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyMagentoHasValueMin(); $maxQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyMagentoHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { return true; } } if ($amazonSynchronizationTemplate->isStopWhenQtyCalculatedHasValue()) { $productQty = (int) $amazonListingProduct->getQty(false); $typeQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyCalculatedHasValueType(); $minQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyCalculatedHasValueMin(); $maxQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyCalculatedHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { return true; } } return false; }
public function isMeetStopRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct) { // Is checked before? //-------------------- if (in_array($listingProduct->getId(), $this->_checkedStopListingsProductsIds)) { return false; } else { $this->_checkedStopListingsProductsIds[] = $listingProduct->getId(); } //-------------------- // Play available status //-------------------- if (!$listingProduct->isListed()) { return false; } if (!$listingProduct->isStoppable()) { return false; } if ($this->_runnerActions->isExistProductAction($listingProduct, Ess_M2ePro_Model_Connector_Server_Play_Product_Dispatcher::ACTION_STOP, array())) { return false; } if ($listingProduct->isLockedObject(NULL) || $listingProduct->isLockedObject('in_action')) { return false; } //-------------------- $productsIdsForEachVariation = NULL; // Check filters //-------------------- if ($listingProduct->getChildObject()->getPlaySynchronizationTemplate()->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) { $statusesTemp = $listingProduct->getVariationsStatuses($productsIdsForEachVariation); if ((int) min($statusesTemp) == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) { return true; } } } } if ($listingProduct->getChildObject()->getPlaySynchronizationTemplate()->isStopOutOfStock()) { if (!$listingProduct->getMagentoProduct()->getStockAvailability()) { return true; } else { if (is_null($productsIdsForEachVariation)) { $productsIdsForEachVariation = $listingProduct->getProductsIdsForEachVariation(); } if (count($productsIdsForEachVariation) > 0) { $stockAvailabilityTemp = $listingProduct->getVariationsStockAvailabilities($productsIdsForEachVariation); if (!(int) max($stockAvailabilityTemp)) { return true; } } } } if ($listingProduct->getChildObject()->getPlaySynchronizationTemplate()->isStopWhenQtyHasValue()) { $productQty = (int) $listingProduct->getChildObject()->getQty(true); $playSynchronizationTemplate = $listingProduct->getChildObject()->getPlaySynchronizationTemplate(); $typeQty = (int) $playSynchronizationTemplate->getStopWhenQtyHasValueType(); $minQty = (int) $playSynchronizationTemplate->getStopWhenQtyHasValueMin(); $maxQty = (int) $playSynchronizationTemplate->getStopWhenQtyHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Play_Template_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Play_Template_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Play_Template_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { return true; } } //-------------------- return false; }
public function isMeetStopRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct) { // Is checked before? //-------------------- if (in_array($listingProduct->getId(), $this->_checkedStopListingsProductsIds)) { return false; } else { $this->_checkedStopListingsProductsIds[] = $listingProduct->getId(); } //-------------------- // Amazon available status //-------------------- if (!$listingProduct->isListed() || $listingProduct->isBlocked()) { return false; } if (!$listingProduct->isStoppable()) { return false; } if ($this->getRunner()->isExistProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_STOP, 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 ($listingProduct->getChildObject()->isVariationProduct() && !$listingProduct->getChildObject()->isVariationMatched()) { return false; } //-------------------- $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation'); // Check filters //-------------------- if ($amazonSynchronizationTemplate->isStopStatusDisabled()) { if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) { return true; } else { if ($listingProduct->getChildObject()->isVariationsReady()) { $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return true; } } } } if ($amazonSynchronizationTemplate->isStopOutOfStock()) { if (!$listingProduct->getMagentoProduct()->isStockAvailability()) { return true; } else { if ($listingProduct->getChildObject()->isVariationsReady()) { $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return true; } } } } if ($amazonSynchronizationTemplate->isStopWhenQtyHasValue()) { $productQty = (int) $listingProduct->getChildObject()->getQty(true); $typeQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyHasValueType(); $minQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyHasValueMin(); $maxQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { return true; } } //-------------------- return false; }
/** * @param Ess_M2ePro_Model_Listing_Product $listingProduct * @return bool * @throws Ess_M2ePro_Model_Exception_Logic */ public function isMeetStopRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct) { if (!$listingProduct->isListed()) { return false; } if (!$listingProduct->isStoppable() || $listingProduct->isHidden()) { return false; } /** @var Ess_M2ePro_Model_Ebay_Listing_Product $ebayListingProduct */ $ebayListingProduct = $listingProduct->getChildObject(); $ebaySynchronizationTemplate = $ebayListingProduct->getEbaySynchronizationTemplate(); if (!$ebayListingProduct->isSetCategoryTemplate()) { return false; } $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation'); if ($ebaySynchronizationTemplate->isStopStatusDisabled()) { if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) { return true; } else { if ($ebayListingProduct->isVariationsReady()) { $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return true; } } } } if ($ebaySynchronizationTemplate->isStopOutOfStock()) { if (!$listingProduct->getMagentoProduct()->isStockAvailability()) { return true; } else { if ($ebayListingProduct->isVariationsReady()) { $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return true; } } } } if ($ebaySynchronizationTemplate->isStopWhenQtyMagentoHasValue()) { $productQty = (int) $listingProduct->getMagentoProduct()->getQty(true); $typeQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyMagentoHasValueType(); $minQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyMagentoHasValueMin(); $maxQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyMagentoHasValueMax(); 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; } } if ($ebaySynchronizationTemplate->isStopWhenQtyCalculatedHasValue()) { $productQty = (int) $ebayListingProduct->getQty(); $typeQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyCalculatedHasValueType(); $minQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyCalculatedHasValueMin(); $maxQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyCalculatedHasValueMax(); 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; }
/** * @param Ess_M2ePro_Model_Listing_Product $childListingProduct * @return bool */ public function tryToRemoveChildListingProduct(Ess_M2ePro_Model_Listing_Product $childListingProduct) { if ($childListingProduct->isLocked()) { return false; } if ($childListingProduct->isStoppable()) { Mage::getModel('M2ePro/StopQueue')->add($childListingProduct); } $this->getTypeModel()->removeChildListingProduct($childListingProduct->getId()); return true; }
public function tryToDeleteChildListingProduct(Ess_M2ePro_Model_Listing_Product $childListingProduct) { if ($childListingProduct->isLocked()) { return false; } if ($childListingProduct->isStoppable()) { Mage::getModel('M2ePro/StopQueue')->add($childListingProduct); } $childListingProduct->deleteInstance(); unset($this->childListingProducts[$childListingProduct->getId()]); return true; }
public function isMeetStopRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct) { // Is checked before? //-------------------- if (in_array($listingProduct->getId(), $this->checkedStopListingsProductsIds)) { return false; } else { $this->checkedStopListingsProductsIds[] = $listingProduct->getId(); } //-------------------- // eBay available status //-------------------- if (!$listingProduct->isListed()) { return false; } if (!$listingProduct->isStoppable() || $listingProduct->isHidden()) { return false; } $tempActionAndParams = $this->getRunnerStopDataByListingProduct($listingProduct); if ($this->getRunner()->isExistProduct($listingProduct, $tempActionAndParams['action'], $tempActionAndParams['params'])) { return false; } //-------------------- /* @var $ebaySynchronizationTemplate Ess_M2ePro_Model_Ebay_Template_Synchronization */ $ebaySynchronizationTemplate = $listingProduct->getChildObject()->getEbaySynchronizationTemplate(); // Correct synchronization //-------------------- if (!$listingProduct->getChildObject()->isSetCategoryTemplate()) { return false; } //-------------------- $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation'); // Check filters //-------------------- if ($ebaySynchronizationTemplate->isStopStatusDisabled()) { if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) { return true; } else { if ($listingProduct->getChildObject()->isVariationsReady()) { $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return true; } } } } if ($ebaySynchronizationTemplate->isStopOutOfStock()) { if (!$listingProduct->getMagentoProduct()->isStockAvailability()) { return true; } else { if ($listingProduct->getChildObject()->isVariationsReady()) { $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId()); if (!is_null($temp) && $temp) { return true; } } } } if ($ebaySynchronizationTemplate->isStopWhenQtyHasValue()) { $productQty = (int) $listingProduct->getMagentoProduct()->getQty(true); $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; }
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; }