/**
  * @param Ess_M2ePro_Model_Listing_Product $listingProduct
  * @return bool
  * @throws Ess_M2ePro_Model_Exception
  * @throws Ess_M2ePro_Model_Exception_Logic
  * @throws Exception
  */
 public function isMeetListRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     if (!$listingProduct->isNotListed() || $listingProduct->isBlocked()) {
         return false;
     }
     if (!$listingProduct->isListable()) {
         return false;
     }
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     $variationManager = $amazonListingProduct->getVariationManager();
     $searchGeneralId = $amazonListingProduct->getListingSource()->getSearchGeneralId();
     $searchWorldwideId = $amazonListingProduct->getListingSource()->getSearchWorldwideId();
     if ($variationManager->isVariationProduct()) {
         if ($variationManager->isPhysicalUnit() && !$variationManager->getTypeModel()->isVariationProductMatched()) {
             return false;
         }
         if ($variationManager->isRelationParentType() && $amazonListingProduct->getGeneralId()) {
             return false;
         }
         if ($variationManager->isRelationChildType()) {
             if (!$amazonListingProduct->getGeneralId() && !$amazonListingProduct->isGeneralIdOwner()) {
                 return false;
             }
         }
         if ($variationManager->isIndividualType()) {
             if (!$amazonListingProduct->getGeneralId() && ($listingProduct->getMagentoProduct()->isSimpleTypeWithCustomOptions() || $listingProduct->getMagentoProduct()->isBundleType())) {
                 return false;
             }
         }
         if ($variationManager->isRelationParentType() && empty($searchGeneralId) && !$amazonListingProduct->isGeneralIdOwner()) {
             return false;
         }
     }
     if (!$amazonListingProduct->getGeneralId() && !$amazonListingProduct->isGeneralIdOwner() && empty($searchGeneralId) && empty($searchWorldwideId)) {
         return false;
     }
     $amazonSynchronizationTemplate = $amazonListingProduct->getAmazonSynchronizationTemplate();
     if (!$amazonSynchronizationTemplate->isListMode()) {
         return false;
     }
     if ($listingProduct->isLockedObject('in_action')) {
         return false;
     }
     $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation');
     $additionalData = $listingProduct->getAdditionalData();
     if ($amazonSynchronizationTemplate->isListStatusEnabled()) {
         if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) {
             // M2ePro_TRANSLATIONS
             // Product was not automatically Listed according to the List Rules in Synchronization Policy. Status of Magento Product is Disabled (%date%) though in Synchronization Rules “Product Status” is set to Enabled.
             $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                  Status of Magento Product is Disabled (%date%) though in Synchronization Rules “Product Status”
                  is set to Enabled.', array('date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             $additionalData['synch_template_list_rules_note'] = $note;
             $listingProduct->setSettings('additional_data', $additionalData)->save();
             return false;
         } else {
             if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) {
                 $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     // M2ePro_TRANSLATIONS
                     // Product was not automatically Listed according to the List Rules in Synchronization Policy. Status of Magento Product Variation is Disabled (%date%) though in Synchronization Rules “Product Status“ is set to Enabled.
                     $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Status of Magento Product Variation is Disabled (%date%) though in Synchronization Rules
                      “Product Status“ is set to Enabled.', array('date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
                     $additionalData['synch_template_list_rules_note'] = $note;
                     $listingProduct->setSettings('additional_data', $additionalData)->save();
                     return false;
                 }
             }
         }
     }
     if ($amazonSynchronizationTemplate->isListIsInStock()) {
         if (!$listingProduct->getMagentoProduct()->isStockAvailability()) {
             // M2ePro_TRANSLATIONS
             // Product was not automatically Listed according to the List Rules in Synchronization Policy. Stock Availability of Magento Product is Out of Stock though in Synchronization Rules “Stock Availability” is set to In Stock.
             $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                  Stock Availability of Magento Product is Out of Stock though in
                  Synchronization Rules “Stock Availability” is set to In Stock.', array('date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             $additionalData['synch_template_list_rules_note'] = $note;
             $listingProduct->setSettings('additional_data', $additionalData)->save();
             return false;
         } else {
             if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) {
                 $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     // M2ePro_TRANSLATIONS
                     // Product was not automatically Listed according to the List Rules in Synchronization Policy. Stock Availability of Magento Product Variation is Out of Stock though in Synchronization Rules “Stock Availability” is set to In Stock.
                     $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Stock Availability of Magento Product Variation is Out of Stock though
                      in Synchronization Rules “Stock Availability” is set to In Stock.', array('date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
                     $additionalData['synch_template_list_rules_note'] = $note;
                     $listingProduct->setSettings('additional_data', $additionalData)->save();
                     return false;
                 }
             }
         }
     }
     if ($amazonSynchronizationTemplate->isListWhenQtyMagentoHasValue()) {
         $result = false;
         if ($variationManager->isRelationParentType()) {
             $productQty = (int) $listingProduct->getMagentoProduct()->getQty(true);
         } else {
             $productQty = (int) $amazonListingProduct->getQty(true);
         }
         $typeQty = (int) $amazonSynchronizationTemplate->getListWhenQtyMagentoHasValueType();
         $minQty = (int) $amazonSynchronizationTemplate->getListWhenQtyMagentoHasValueMin();
         $maxQty = (int) $amazonSynchronizationTemplate->getListWhenQtyMagentoHasValueMax();
         $note = '';
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::LIST_QTY_LESS) {
             if ($productQty <= $minQty) {
                 $result = true;
             } else {
                 // M2ePro_TRANSLATIONS
                 // Product was not automatically Listed according to the List Rules in Synchronization Policy. Quantity of Magento Product is %product_qty% though in Synchronization Rules “Magento Quantity“ is set to less then  %template_min_qty%.
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Magento Quantity“ is set to less then  %template_min_qty%.', array('!template_min_qty' => $minQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::LIST_QTY_MORE) {
             if ($productQty >= $minQty) {
                 $result = true;
             } else {
                 // M2ePro_TRANSLATIONS
                 // Product was not automatically Listed according to the List Rules in Synchronization Policy. Quantity of Magento Product is %product_qty% though in Synchronization Rules “Magento Quantity” is set to more then  %template_min_qty%.
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Magento Quantity” is set to more then  %template_min_qty%.', array('!template_min_qty' => $minQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::LIST_QTY_BETWEEN) {
             if ($productQty >= $minQty && $productQty <= $maxQty) {
                 $result = true;
             } else {
                 // M2ePro_TRANSLATIONS
                 // Product was not automatically Listed according to the List Rules in Synchronization Policy. Quantity of Magento Product is %product_qty% though in Synchronization Rules “Magento Quantity” is set between  %template_min_qty% and %template_max_qty%.
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Magento Quantity” is set between  %template_min_qty% and %template_max_qty%.', array('!template_min_qty' => $minQty, '!template_max_qty' => $maxQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if (!$result) {
             if (!empty($note)) {
                 $additionalData['synch_template_list_rules_note'] = $note;
                 $listingProduct->setSettings('additional_data', $additionalData)->save();
             }
             return false;
         }
     }
     if ($amazonSynchronizationTemplate->isListWhenQtyCalculatedHasValue() && !$variationManager->isRelationParentType()) {
         $result = false;
         $productQty = (int) $amazonListingProduct->getQty(false);
         $typeQty = (int) $amazonSynchronizationTemplate->getListWhenQtyCalculatedHasValueType();
         $minQty = (int) $amazonSynchronizationTemplate->getListWhenQtyCalculatedHasValueMin();
         $maxQty = (int) $amazonSynchronizationTemplate->getListWhenQtyCalculatedHasValueMax();
         $note = '';
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::LIST_QTY_LESS) {
             if ($productQty <= $minQty) {
                 $result = true;
             } else {
                 // M2ePro_TRANSLATIONS
                 // Product was not automatically Listed according to the List Rules in Synchronization Policy. Quantity of Magento Product is %product_qty% though in Synchronization Rules “Calculated Quantity” is set to less then %template_min_qty%.
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Calculated Quantity” is set to less then %template_min_qty%.', array('!template_min_qty' => $minQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::LIST_QTY_MORE) {
             if ($productQty >= $minQty) {
                 $result = true;
             } else {
                 // M2ePro_TRANSLATIONS
                 // Product was not automatically Listed according to the List Rules in Synchronization Policy. Quantity of Magento Product is %product_qty% though in Synchronization Rules “Calculated Quantity” is set to more then  %template_min_qty%.
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Calculated Quantity” is set to more then  %template_min_qty%.', array('!template_min_qty' => $minQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::LIST_QTY_BETWEEN) {
             if ($productQty >= $minQty && $productQty <= $maxQty) {
                 $result = true;
             } else {
                 // M2ePro_TRANSLATIONS
                 // Product was not automatically Listed according to the List Rules in Synchronization Policy. Quantity of Magento Product is %product_qty% though in Synchronization Rules “Calculated Quantity” is set between  %template_min_qty% and %template_max_qty%.
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Calculated Quantity” is set between  %template_min_qty% and %template_max_qty%.', array('!template_min_qty' => $minQty, '!template_max_qty' => $maxQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if (!$result) {
             if (!empty($note)) {
                 $additionalData['synch_template_list_rules_note'] = $note;
                 $listingProduct->setSettings('additional_data', $additionalData)->save();
             }
             return false;
         }
     }
     if ($listingProduct->getSynchStatus() != Ess_M2ePro_Model_Listing_Product::SYNCH_STATUS_NEED && $this->isTriedToList($listingProduct) && $this->isChangeInitiatorOnlyInspector($listingProduct)) {
         return false;
     }
     return true;
 }
Beispiel #2
0
 public function isMeetListRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedListListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedListListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // Play available status
     //--------------------
     if (!$listingProduct->isNotListed()) {
         return false;
     }
     if (!$listingProduct->isListable()) {
         return false;
     }
     if ($this->_runnerActions->isExistProductAction($listingProduct, Ess_M2ePro_Model_Connector_Server_Play_Product_Dispatcher::ACTION_LIST, array())) {
         return false;
     }
     if ($listingProduct->isLockedObject(NULL) || $listingProduct->isLockedObject('in_action')) {
         return false;
     }
     //--------------------
     // Correct synchronization
     //--------------------
     if (!$listingProduct->getChildObject()->getPlaySynchronizationTemplate()->isListMode()) {
         return false;
     }
     //--------------------
     $productsIdsForEachVariation = NULL;
     // Check filters
     //--------------------
     if ($listingProduct->getChildObject()->getPlaySynchronizationTemplate()->isListStatusEnabled()) {
         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()->isListIsInStock()) {
         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()->isListWhenQtyHasValue()) {
         $result = false;
         $productQty = (int) $listingProduct->getChildObject()->getQty(true);
         $playSynchronizationTemplate = $listingProduct->getChildObject()->getPlaySynchronizationTemplate();
         $typeQty = (int) $playSynchronizationTemplate->getListWhenQtyHasValueType();
         $minQty = (int) $playSynchronizationTemplate->getListWhenQtyHasValueMin();
         $maxQty = (int) $playSynchronizationTemplate->getListWhenQtyHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Play_Template_Synchronization::LIST_QTY_LESS && $productQty <= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Play_Template_Synchronization::LIST_QTY_MORE && $productQty >= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Play_Template_Synchronization::LIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             $result = true;
         }
         if (!$result) {
             return false;
         }
     }
     //--------------------
     return true;
 }
Beispiel #3
0
 public function isMeetListRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // Is checked before?
     //--------------------
     if (in_array($listingProduct->getId(), $this->_checkedListListingsProductsIds)) {
         return false;
     } else {
         $this->_checkedListListingsProductsIds[] = $listingProduct->getId();
     }
     //--------------------
     // Amazon available status
     //--------------------
     if (!$listingProduct->isNotListed() || $listingProduct->isBlocked()) {
         return false;
     }
     if (!$listingProduct->isListable()) {
         return false;
     }
     if ($this->getRunner()->isExistProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_LIST, 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->isListMode()) {
         return false;
     }
     if ($listingProduct->getChildObject()->isVariationProduct() && !$listingProduct->getChildObject()->isVariationMatched()) {
         return false;
     }
     //--------------------
     $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation');
     // Check filters
     //--------------------
     if ($amazonSynchronizationTemplate->isListStatusEnabled()) {
         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->isListIsInStock()) {
         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->isListWhenQtyHasValue()) {
         $result = false;
         $productQty = (int) $listingProduct->getChildObject()->getQty(true);
         $typeQty = (int) $amazonSynchronizationTemplate->getListWhenQtyHasValueType();
         $minQty = (int) $amazonSynchronizationTemplate->getListWhenQtyHasValueMin();
         $maxQty = (int) $amazonSynchronizationTemplate->getListWhenQtyHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::LIST_QTY_LESS && $productQty <= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::LIST_QTY_MORE && $productQty >= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::LIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             $result = true;
         }
         if (!$result) {
             return false;
         }
     }
     //--------------------
     return true;
 }
Beispiel #4
0
 private function isMeetListRequirements(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->isNotListed()) {
         return false;
     }
     if (!$listingProduct->isListable()) {
         return false;
     }
     if ($this->_runnerActions->isExistProductAction($listingProduct, Ess_M2ePro_Model_Connector_Server_Ebay_Item_Dispatcher::ACTION_LIST, 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->isListMode()) {
         return false;
     }
     if ($ebaySynchronizationTemplate->isScheduleEnabled()) {
         if (!$ebaySynchronizationTemplate->isScheduleIntervalNow() || !$ebaySynchronizationTemplate->isScheduleWeekNow()) {
             return false;
         }
     }
     //--------------------
     $productsIdsForEachVariation = NULL;
     // Check filters
     //--------------------
     if ($ebaySynchronizationTemplate->isListStatusEnabled()) {
         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->isListIsInStock()) {
         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->isListWhenQtyHasValue()) {
         $result = false;
         $productQty = (int) $listingProduct->getChildObject()->getQty(true);
         $typeQty = (int) $ebaySynchronizationTemplate->getListWhenQtyHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getListWhenQtyHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getListWhenQtyHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::LIST_QTY_LESS && $productQty <= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::LIST_QTY_MORE && $productQty >= $minQty) {
             $result = true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::LIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             $result = true;
         }
         if (!$result) {
             return false;
         }
     }
     //--------------------
     return true;
 }
Beispiel #5
0
 public function isMeetListRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     if (!$listingProduct->isNotListed()) {
         return false;
     }
     if (!$listingProduct->isListable()) {
         return false;
     }
     /** @var Ess_M2ePro_Model_Ebay_Listing_Product $ebayListingProduct */
     $ebayListingProduct = $listingProduct->getChildObject();
     $ebaySynchronizationTemplate = $ebayListingProduct->getEbaySynchronizationTemplate();
     if (!$ebaySynchronizationTemplate->isListMode()) {
         return false;
     }
     $additionalData = $listingProduct->getAdditionalData();
     if ($ebaySynchronizationTemplate->isScheduleEnabled() && (!$ebaySynchronizationTemplate->isScheduleIntervalNow() || !$ebaySynchronizationTemplate->isScheduleWeekNow())) {
         $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the Schedule Settings in Synchronization Policy.', array('date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
         $additionalData['synch_template_list_rules_note'] = $note;
         $listingProduct->setSettings('additional_data', $additionalData)->save();
         return false;
     }
     if (!$ebayListingProduct->isSetCategoryTemplate()) {
         return false;
     }
     $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation');
     if ($ebaySynchronizationTemplate->isListStatusEnabled()) {
         if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) {
             $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                  Status of Magento Product is Disabled (%date%) though in Synchronization Rules “Product Status”
                  is set to Enabled.', array('date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             $additionalData['synch_template_list_rules_note'] = $note;
             $listingProduct->setSettings('additional_data', $additionalData)->save();
             return false;
         } else {
             if ($ebayListingProduct->isVariationsReady()) {
                 $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Status of Magento Product Variation is Disabled (%date%) though in Synchronization Rules
                      “Product Status“ is set to Enabled.', array('date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
                     $additionalData['synch_template_list_rules_note'] = $note;
                     $listingProduct->setSettings('additional_data', $additionalData)->save();
                     return false;
                 }
             }
         }
     }
     if ($ebaySynchronizationTemplate->isListIsInStock()) {
         if (!$listingProduct->getMagentoProduct()->isStockAvailability()) {
             $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                  Stock Availability of Magento Product is Out of Stock though in
                  Synchronization Rules “Stock Availability” is set to In Stock.', array('date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             $additionalData['synch_template_list_rules_note'] = $note;
             $listingProduct->setSettings('additional_data', $additionalData)->save();
             return false;
         } else {
             if ($ebayListingProduct->isVariationsReady()) {
                 $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Stock Availability of Magento Product Variation is Out of Stock though
                      in Synchronization Rules “Stock Availability” is set to In Stock.', array('date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
                     $additionalData['synch_template_list_rules_note'] = $note;
                     $listingProduct->setSettings('additional_data', $additionalData)->save();
                     return false;
                 }
             }
         }
     }
     if ($ebaySynchronizationTemplate->isListWhenQtyMagentoHasValue()) {
         $result = false;
         $productQty = (int) $listingProduct->getMagentoProduct()->getQty(true);
         $typeQty = (int) $ebaySynchronizationTemplate->getListWhenQtyMagentoHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getListWhenQtyMagentoHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getListWhenQtyMagentoHasValueMax();
         $note = '';
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::LIST_QTY_LESS) {
             if ($productQty <= $minQty) {
                 $result = true;
             } else {
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Magento Quantity“ is set to less then  %template_min_qty%.', array('!template_min_qty' => $minQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::LIST_QTY_MORE) {
             if ($productQty >= $minQty) {
                 $result = true;
             } else {
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Magento Quantity” is set to more then  %template_min_qty%.', array('!template_min_qty' => $minQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::LIST_QTY_BETWEEN) {
             if ($productQty >= $minQty && $productQty <= $maxQty) {
                 $result = true;
             } else {
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Magento Quantity” is set between  %template_min_qty% and %template_max_qty%', array('!template_min_qty' => $minQty, '!template_max_qty' => $maxQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if (!$result) {
             if (!empty($note)) {
                 $additionalData['synch_template_list_rules_note'] = $note;
                 $listingProduct->setSettings('additional_data', $additionalData)->save();
             }
             return false;
         }
     }
     if ($ebaySynchronizationTemplate->isListWhenQtyCalculatedHasValue()) {
         $result = false;
         $productQty = (int) $ebayListingProduct->getQty();
         $typeQty = (int) $ebaySynchronizationTemplate->getListWhenQtyCalculatedHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getListWhenQtyCalculatedHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getListWhenQtyCalculatedHasValueMax();
         $note = '';
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::LIST_QTY_LESS) {
             if ($productQty <= $minQty) {
                 $result = true;
             } else {
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Calculated Quantity” is set to less then %template_min_qty%', array('!template_min_qty' => $minQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::LIST_QTY_MORE) {
             if ($productQty >= $minQty) {
                 $result = true;
             } else {
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Calculated Quantity” is set to more then  %template_min_qty%.', array('!template_min_qty' => $minQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::LIST_QTY_BETWEEN) {
             if ($productQty >= $minQty && $productQty <= $maxQty) {
                 $result = true;
             } else {
                 $note = Mage::getSingleton('M2ePro/Log_Abstract')->encodeDescription('Product was not automatically Listed according to the List Rules in Synchronization Policy.
                      Quantity of Magento Product is %product_qty% though in Synchronization Rules
                      “Calculated Quantity” is set between  %template_min_qty% and %template_max_qty%.', array('!template_min_qty' => $minQty, '!template_max_qty' => $maxQty, '!product_qty' => $productQty, '!date' => Mage::helper('M2ePro')->getCurrentGmtDate()));
             }
         }
         if (!$result) {
             if (!empty($note)) {
                 $additionalData['synch_template_list_rules_note'] = $note;
                 $listingProduct->setSettings('additional_data', $additionalData)->save();
             }
             return false;
         }
     }
     if ($listingProduct->getSynchStatus() != Ess_M2ePro_Model_Listing_Product::SYNCH_STATUS_NEED && $this->isTriedToList($listingProduct) && $this->isChangeInitiatorOnlyInspector($listingProduct)) {
         return false;
     }
     return true;
 }