/** * @param \Ess\M2ePro\Model\Listing\Product $listingProduct * @return bool * @throws \Ess\M2ePro\Model\Exception\Logic */ 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); $this->activeRecordFactory->getObject('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->isSetProcessingLock('in_action')) { return false; } $amazonSynchronizationTemplate = $amazonListingProduct->getAmazonSynchronizationTemplate(); $variationResource = $this->activeRecordFactory->getObject('Listing\\Product\\Variation')->getResource(); 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; }
/** * @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()) { $this->modelFactory->getObject('StopQueue')->add($childListingProduct); } $this->getTypeModel()->removeChildListingProduct($childListingProduct->getId()); return true; }
/** * @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; } if ($listingProduct->isSetProcessingLock('in_action')) { return false; } $variationResource = $this->activeRecordFactory->getObject('Listing\\Product\\Variation')->getResource(); 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; }