Ejemplo n.º 1
0
 private function saveVariationsSets(Ess_M2ePro_Model_Listing_Product $listingProduct, $variations)
 {
     if (!isset($variations['set'])) {
         return;
     }
     $additionalData = $listingProduct->getChildObject()->getData('additional_data');
     $additionalData = is_null($additionalData) ? array() : json_decode($additionalData, true);
     $additionalData['variations_sets'] = $variations['set'];
     $listingProduct->getChildObject()->setData('additional_data', json_encode($additionalData))->save();
 }
Ejemplo n.º 2
0
 private function checkVariationStructureChanges(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager $variationManager */
     $variationManager = $listingProduct->getChildObject()->getVariationManager();
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Abstract $typeModel */
     $typeModel = $variationManager->getTypeModel();
     if ($variationManager->isRelationParentType()) {
         $this->parentListingsProductsForProcessing[$listingProduct->getId()] = $listingProduct;
         return;
     }
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_PhysicalUnit $typeModel */
     if (!$typeModel->isActualProductAttributes()) {
         if ($variationManager->isRelationChildType()) {
             /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $typeModel */
             $this->parentListingsProductsForProcessing[$typeModel->getParentListingProduct()->getId()] = $typeModel->getParentListingProduct();
             return;
         }
         /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Individual $typeModel */
         $typeModel->resetProductVariation();
         return;
     }
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_PhysicalUnit $typeModel */
     if ($typeModel->isVariationProductMatched() && !$typeModel->isActualProductVariation()) {
         if ($variationManager->isRelationChildType()) {
             /** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Child $typeModel */
             $this->parentListingsProductsForProcessing[$typeModel->getParentListingProduct()->getId()] = $typeModel->getParentListingProduct();
             return;
         }
         $typeModel->unsetProductVariation();
     }
 }
Ejemplo n.º 3
0
 private function getConnectorParams()
 {
     $searchMethod = $this->getSearchMethod();
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
     $amazonListingProduct = $this->listingProduct->getChildObject();
     $isModifyChildToSimple = !$amazonListingProduct->getVariationManager()->isRelationParentType();
     $params = array('variation_bad_parent_modify_child_to_simple' => $isModifyChildToSimple);
     if ($searchMethod == 'byQuery') {
         $params['query'] = $this->query;
     } else {
         $params['query'] = $this->getStrippedQuery();
     }
     if ($searchMethod == 'byIdentifier') {
         $params['query_type'] = $this->getIdentifierType();
     }
     return $params;
 }
Ejemplo n.º 4
0
 public function getRequestData(Ess_M2ePro_Model_Listing_Product $listingProduct, array &$requestData)
 {
     /** @var $categoryTemplate Ess_M2ePro_Model_Ebay_Template_Category */
     $categoryTemplate = $listingProduct->getChildObject()->getCategoryTemplate();
     $categoryTemplate->setMagentoProduct($listingProduct->getMagentoProduct());
     /** @var $otherCategoryTemplate Ess_M2ePro_Model_Ebay_Template_OtherCategory */
     $otherCategoryTemplate = $listingProduct->getChildObject()->getOtherCategoryTemplate();
     if (!is_null($otherCategoryTemplate)) {
         $otherCategoryTemplate->setMagentoProduct($listingProduct->getMagentoProduct());
     }
     $this->addMainCategoriesData($categoryTemplate, $otherCategoryTemplate, $requestData);
     $this->addStoreCategoriesData($otherCategoryTemplate, $requestData);
     $this->addMotorsSpecificsData($listingProduct, $listingProduct->getListing()->getMarketplace(), $categoryTemplate, $requestData);
     $this->addItemSpecificsData($listingProduct, $categoryTemplate, $requestData);
     $this->addCustomItemSpecificsData($listingProduct, $categoryTemplate, $requestData);
     $this->clearConflictedItemSpecificsData($requestData);
     $this->addAttributeSetData($listingProduct, $categoryTemplate, $requestData);
 }
Ejemplo n.º 5
0
 private function getRunnerData(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     /** @var Ess_M2ePro_Model_Ebay_Listing_Product $ebayListingProduct */
     $ebayListingProduct = $listingProduct->getChildObject();
     if (!$ebayListingProduct->getEbaySellingFormatTemplate()->getOutOfStockControl()) {
         return array('action' => Ess_M2ePro_Model_Listing_Product::ACTION_STOP, 'params' => array());
     }
     return array('action' => Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, 'params' => array('replaced_action' => Ess_M2ePro_Model_Listing_Product::ACTION_STOP, 'only_data' => array('qty' => true, 'variations' => true)));
 }
Ejemplo n.º 6
0
 public function processSucceededResponseData($receivedItems)
 {
     if ($this->currentStep == Ess_M2ePro_Model_Buy_Search_Automatic_Requester::STEP_MAGENTO_TITLE) {
         $tempReceivedItems = $this->filterReceivedItemsFullTitleMatch($receivedItems);
         count($tempReceivedItems) == 1 && ($receivedItems = $tempReceivedItems);
     }
     $childListingProduct = $this->listingProduct->getChildObject();
     if (count($receivedItems) <= 0) {
         $temp = Ess_M2ePro_Model_Buy_Search_Automatic_Requester::STEP_MAGENTO_TITLE;
         if ($this->currentStep >= $temp) {
             $childListingProduct->setData('general_id_search_status', Ess_M2ePro_Model_Buy_Listing_Product::GENERAL_ID_SEARCH_STATUS_NONE);
             $message = Mage::helper('M2ePro')->__('The Product(s) was not found on Rakuten.com.');
             $childListingProduct->setData('general_id_search_suggest_data', json_encode(array('message' => $message)));
             $childListingProduct->save();
             return;
         }
         $params = array('listing_product' => $this->listingProduct, 'step' => $this->currentStep + 1);
         $dispatcherObject = Mage::getModel('M2ePro/Buy_Connector')->getDispatcher();
         $dispatcherObject->processConnector('search', 'automatic', 'requester', $params, $this->getMarketplace(), $this->getAccount(), 'Ess_M2ePro_Model_Buy');
         return;
     }
     if (count($receivedItems) == 1) {
         if (!isset($receivedItems[0]['variations'])) {
             $childListingProduct->setData('general_id', $receivedItems[0]['general_id']);
             $childListingProduct->setData('general_id_search_status', Ess_M2ePro_Model_Buy_Listing_Product::GENERAL_ID_SEARCH_STATUS_SET_AUTOMATIC);
             $childListingProduct->setData('general_id_search_suggest_data', NULL);
             $childListingProduct->save();
             return;
         }
         if (count($receivedItems[0]['variations']['skus']) == 1) {
             reset($receivedItems[0]['variations']['skus']);
             $childListingProduct->setData('general_id', key($receivedItems[0]['variations']['skus']));
             $childListingProduct->setData('general_id_search_status', Ess_M2ePro_Model_Buy_Listing_Product::GENERAL_ID_SEARCH_STATUS_SET_AUTOMATIC);
             $childListingProduct->setData('general_id_search_suggest_data', NULL);
             $childListingProduct->save();
             return;
         }
     }
     $childListingProduct->setData('general_id_search_status', Ess_M2ePro_Model_Buy_Listing_Product::GENERAL_ID_SEARCH_STATUS_NONE);
     $childListingProduct->setData('general_id_search_suggest_data', json_encode($receivedItems));
     $childListingProduct->save();
 }
 protected function processSuccess(Ess_M2ePro_Model_Listing_Product $listingProduct, array $params = array())
 {
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     if ($amazonListingProduct->getVariationManager()->isRelationMode() && !$this->getRequestDataObject($listingProduct)->hasProductId() && empty($params['general_id'])) {
         $this->getLogger()->logListingProductMessage($listingProduct, 'Unexpected error. The ASIN/ISBN for Parent or Child Product was not returned from Amazon.
              Operation cannot be finished correctly.', Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
         return;
     }
     parent::processSuccess($listingProduct, $params);
 }
Ejemplo n.º 8
0
 private function checkVariationStructureChanges(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     /** @var Ess_M2ePro_Model_Buy_Listing_Product_Variation_Manager $variationManager */
     $variationManager = $listingProduct->getChildObject()->getVariationManager();
     if (!$variationManager->isActualProductAttributes()) {
         $variationManager->resetProductVariation();
         return;
     }
     if ($variationManager->isVariationProductMatched() && !$variationManager->isActualProductVariation()) {
         $variationManager->unsetProductVariation();
     }
 }
Ejemplo n.º 9
0
 private function calculateCurrentData()
 {
     if (!empty($this->currentQuery) || $this->currentStep > self::STEP_MAGENTO_TITLE) {
         return;
     }
     /** @var $listing Ess_M2ePro_Model_Buy_Listing */
     $listing = $this->listingProduct->getListing()->getChildObject();
     $tempQuery = '';
     switch ($this->currentStep) {
         case self::STEP_GENERAL_ID:
             $tempQuery = $this->listingProduct->getChildObject()->getGeneralId();
             empty($tempQuery) && ($tempQuery = $this->listingProduct->getChildObject()->getAddingGeneralId());
             break;
         case self::STEP_MAGENTO_TITLE:
             if ($listing->isSearchByMagentoTitleModeEnabled()) {
                 $tempQuery = $this->listingProduct->getChildObject()->getActualMagentoProduct()->getName();
             }
             break;
     }
     !empty($tempQuery) ? $this->currentQuery = (string) $tempQuery : $this->currentStep++;
     $this->calculateCurrentData();
 }
Ejemplo n.º 10
0
 private function prepareConfigurator(Ess_M2ePro_Model_Listing_Product $listingProduct, Ess_M2ePro_Model_Ebay_Listing_Product_Action_Configurator $configurator, $action)
 {
     if ($action != Ess_M2ePro_Model_Listing_Product::ACTION_STOP) {
         $configurator->setParams(array('replaced_action' => Ess_M2ePro_Model_Listing_Product::ACTION_STOP));
     }
     /** @var Ess_M2ePro_Model_Ebay_Listing_Product $ebayListingProduct */
     $ebayListingProduct = $listingProduct->getChildObject();
     if (!$ebayListingProduct->getEbaySellingFormatTemplate()->getOutOfStockControl() && $action == Ess_M2ePro_Model_Listing_Product::ACTION_STOP) {
         return;
     }
     $configurator->setPartialMode();
     $configurator->allowQty()->allowVariations();
 }
Ejemplo n.º 11
0
 protected function filterReceivedItemsFullTitleMatch($receivedItems)
 {
     $return = array();
     $magentoProductTitle = $this->listingProduct->getChildObject()->getActualMagentoProduct()->getName();
     $magentoProductTitle = trim(strtolower($magentoProductTitle));
     foreach ($receivedItems as $item) {
         $itemTitle = trim(strtolower($item['title']));
         if ($itemTitle == $magentoProductTitle) {
             $return[] = $item;
         }
     }
     return $return;
 }
Ejemplo n.º 12
0
 public function isAddedNewVariationsAttributes(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     if (!$listingProduct->getChildObject()->isListingTypeFixed() || !$listingProduct->getChildObject()->isVariationMode()) {
         return false;
     }
     if ($listingProduct->getMagentoProduct()->isProductWithoutVariations()) {
         return false;
     }
     $rawMagentoVariations = $listingProduct->getMagentoProduct()->getProductVariations();
     $rawMagentoVariations = $this->validateLimitsConditions($rawMagentoVariations, NULL);
     $magentoVariations = $this->prepareMagentoVariations($rawMagentoVariations);
     $currentVariations = $this->prepareCurrentVariations($listingProduct->getVariations(true));
     if (!isset($magentoVariations[0]) && !isset($currentVariations[0])) {
         return false;
     }
     if (!isset($magentoVariations[0]) || !isset($currentVariations[0])) {
         return true;
     }
     if (count($magentoVariations[0]['options']) != count($currentVariations[0]['options'])) {
         return true;
     }
     return false;
 }
Ejemplo n.º 13
0
 public function processSucceededResponseData($receivedItems, $hash)
 {
     $this->unsetProcessingLock = true;
     $this->unsetLocks($hash);
     $this->unsetProcessingLock = false;
     if ($this->currentStep == Ess_M2ePro_Model_Amazon_Search_Automatic_ByQuery_Requester::STEP_MAGENTO_TITLE) {
         $tempReceivedItems = $this->filterReceivedItemsFullTitleMatch($receivedItems);
         count($tempReceivedItems) == 1 && ($receivedItems = $tempReceivedItems);
     }
     $childListingProduct = $this->listingProduct->getChildObject();
     if (count($receivedItems) <= 0) {
         $temp = Ess_M2ePro_Model_Amazon_Search_Automatic_ByQuery_Requester::STEP_MAGENTO_TITLE;
         if ($this->currentStep >= $temp) {
             $childListingProduct->setData('general_id_search_status', Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_NONE);
             $message = Mage::helper('M2ePro')->__('The Product(s) was not found on Amazon.');
             $childListingProduct->setData('general_id_search_suggest_data', json_encode(array('message' => $message)));
             $childListingProduct->save();
             return;
         }
         $params = array('listing_product' => $this->listingProduct, 'step' => $this->currentStep + 1);
         $dispatcherObject = Mage::getModel('M2ePro/Amazon_Connector')->getDispatcher();
         $dispatcherObject->processConnector('automatic', 'byQuery', 'requester', $params, $this->getMarketplace(), $this->getAccount(), 'Ess_M2ePro_Model_Amazon_Search');
         return;
     }
     if (count($receivedItems) == 1) {
         $childListingProduct->setData('general_id', $receivedItems[0]['general_id']);
         $childListingProduct->setData('is_isbn_general_id', (int) Mage::helper('M2ePro/Component_Amazon')->isISBN($receivedItems[0]['general_id']));
         $temp = Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_SET_AUTOMATIC;
         $childListingProduct->setData('general_id_search_status', $temp);
         $childListingProduct->setData('general_id_search_suggest_data', NULL);
         $childListingProduct->save();
         return;
     }
     $childListingProduct->setData('general_id_search_status', Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_NONE);
     $childListingProduct->setData('general_id_search_suggest_data', json_encode($receivedItems));
     $childListingProduct->save();
 }
Ejemplo n.º 14
0
 private function calculateCurrentData()
 {
     if (!empty($this->currentQuery) || $this->currentStep > self::STEP_MAGENTO_TITLE) {
         return;
     }
     switch ($this->currentStep) {
         case self::STEP_GENERAL_ID:
             $tempQuery = $this->listingProduct->getChildObject()->getGeneralId();
             empty($tempQuery) && ($tempQuery = $this->listingProduct->getChildObject()->getAddingGeneralId());
             !empty($tempQuery) && ($this->currentStep = self::STEP_GENERAL_ID);
             !empty($tempQuery) && ($this->currentQuery = (string) $tempQuery);
             break;
         case self::STEP_MAGENTO_TITLE:
             $tempQuery = '';
             if ($this->listingProduct->getGeneralTemplate()->getChildObject()->isSearchByMagentoTitleModeEnabled()) {
                 $tempQuery = $this->listingProduct->getMagentoProduct()->getName();
             }
             !empty($tempQuery) && ($this->currentStep = self::STEP_MAGENTO_TITLE);
             !empty($tempQuery) && ($this->currentQuery = (string) $tempQuery);
             break;
     }
     empty($this->currentQuery) && $this->currentStep++;
     $this->calculateCurrentData();
 }
Ejemplo n.º 15
0
 private function calculateCurrentData()
 {
     if (!empty($this->currentQuery) || $this->currentStep > self::STEP_MAGENTO_TITLE) {
         return;
     }
     switch ($this->currentStep) {
         case self::STEP_UPC_EAN:
             $tempQuery = $this->listingProduct->getChildObject()->getWorldwideId();
             empty($tempQuery) && ($tempQuery = $this->listingProduct->getChildObject()->getAddingWorldwideId());
             !empty($tempQuery) && ($this->currentStep = self::STEP_UPC_EAN);
             !empty($tempQuery) && ($this->currentQuery = (string) $tempQuery);
             break;
         case self::STEP_MAGENTO_TITLE:
             $tempQuery = '';
             if ($this->listingProduct->getListing()->getChildObject()->isSearchByMagentoTitleModeEnabled()) {
                 $tempQuery = $this->listingProduct->getChildObject()->getActualMagentoProduct()->getName();
             }
             !empty($tempQuery) && ($this->currentStep = self::STEP_MAGENTO_TITLE);
             !empty($tempQuery) && ($this->currentQuery = (string) $tempQuery);
             break;
     }
     empty($this->currentQuery) && $this->currentStep++;
     $this->calculateCurrentData();
 }
Ejemplo n.º 16
0
 public function getRequestData(Ess_M2ePro_Model_Listing_Product $listingProduct, array &$requestData)
 {
     $requestData['shipping'] = array();
     /** @var $shippingTemplate Ess_M2ePro_Model_Ebay_Template_Shipping */
     $shippingTemplate = $listingProduct->getChildObject()->getShippingTemplate();
     $shippingTemplate->setMagentoProduct($listingProduct->getMagentoProduct());
     $accountId = $listingProduct->getListing()->getAccountId();
     $this->addLocalShippingData($shippingTemplate, $accountId, $requestData);
     $this->addInternationalShippingData($shippingTemplate, $accountId, $requestData);
     $this->addGlobalShippingProgramData($shippingTemplate, $requestData);
     $this->addExcludedLocationsData($shippingTemplate, $requestData);
     if ($shippingTemplate->isLocalShippingFlatEnabled() && $shippingTemplate->isLocalShippingRateTableEnabled() && !$shippingTemplate->isInternationalShippingCalculatedEnabled() && !isset($requestData['shipping']['calculated'])) {
         $calculatedData = $this->getCalculatedData($shippingTemplate, $listingProduct);
         unset($calculatedData['package_size']);
         unset($calculatedData['originating_postal_code']);
         unset($calculatedData['dimensions']);
         $requestData['shipping']['calculated'] = $calculatedData;
     }
     $this->addAdditionalData($shippingTemplate, $requestData);
     $this->addLocationData($shippingTemplate, $requestData);
     $this->addInternationalTradeData($shippingTemplate, $requestData);
 }
Ejemplo n.º 17
0
 public function updateVariations(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $options = array();
     if ($listingProduct->getMagentoProduct()->isProductWithoutVariations()) {
         $listingProduct->setData('is_variation_product', Ess_M2ePro_Model_Play_Listing_Product::IS_VARIATION_PRODUCT_NO)->save();
         if ($listingProduct->getChildObject()->isVariationMatched()) {
             $listingProduct->getChildObject()->updateVariationOptions($options);
             $listingProduct->getChildObject()->unsetMatchedVariation();
         }
         return;
     }
     $listingProduct->setData('is_variation_product', Ess_M2ePro_Model_Play_Listing_Product::IS_VARIATION_PRODUCT_YES)->save();
     $magentoVariations = $listingProduct->getMagentoProduct()->getProductVariations();
     foreach ($magentoVariations['set'] as $attribute => $value) {
         $options[] = array('attribute' => $attribute, 'option' => NULL);
     }
     if (!$listingProduct->getChildObject()->isVariationMatched()) {
         $listingProduct->getChildObject()->updateVariationOptions($options);
         return;
     }
     // observe variation removal in Magento
     $currentVariation = $this->prepareCurrentVariations($listingProduct->getVariations(true));
     if (!isset($currentVariation[0]) || !isset($currentVariation[0]['options'])) {
         return;
     }
     $currentVariation = reset($currentVariation);
     $magentoVariations = $this->prepareMagentoVariations($magentoVariations);
     foreach ($magentoVariations as $magentoVariation) {
         if ($this->isEqualVariations($magentoVariation['options'], $currentVariation['options'])) {
             return;
         }
     }
     foreach ($listingProduct->getVariations(true) as $variation) {
         $variation->deleteInstance();
     }
     $listingProduct->getChildObject()->updateVariationOptions($options);
     $listingProduct->getChildObject()->unsetMatchedVariation();
 }
Ejemplo n.º 18
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.º 19
0
 private function isSkuExistsInM2ePro($sku, Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // check in 3rd party by account
     $listingOtherCollection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Listing_Other')->addFieldToFilter('sku', $sku)->addFieldToFilter('account_id', $this->account->getId());
     if ($listingOtherCollection->getSize() > 0) {
         if ($listingProduct->getChildObject()->getAmazonListing()->isGenerateSkuModeNo()) {
             $message = Mage::helper('M2ePro')->__('The same Merchant SKU was found among 3rd Party Listings. ');
             $message .= Mage::helper('M2ePro')->__('Merchant SKU must be unique for each Amazon item.');
             $this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
         }
         return true;
     }
     // check in M2ePro listings by account
     $listingProductCollection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Listing_Product');
     $listingTable = Mage::getResourceModel('M2ePro/Listing')->getMainTable();
     $listingProductCollection->getSelect()->join(array('l' => $listingTable), '`main_table`.`listing_id` = `l`.`id`', array());
     $listingProductCollection->addFieldToFilter('sku', $sku)->addFieldToFilter('account_id', $this->account->getId());
     if ($listingProductCollection->getSize() > 0) {
         if ($listingProduct->getChildObject()->getAmazonListing()->isGenerateSkuModeNo()) {
             $message = Mage::helper('M2ePro')->__('The same Merchant SKU was found among M2E Listings. ');
             $message .= Mage::helper('M2ePro')->__('Merchant SKU must be unique for each Amazon item.');
             $this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
         }
         return true;
     }
     // check in queue of SKUs by account
     $queue = $this->getQueueOfSkus();
     if (in_array($sku, $queue, true) || isset($this->skusToCheck[$sku])) {
         if ($listingProduct->getChildObject()->getAmazonListing()->isGenerateSkuModeNo()) {
             // M2ePro_TRANSLATIONS
             // The product with the same Merchant SKU is being listed now. SKU must be unique for each Amazon item.
             $this->addListingsProductsLogsMessage($listingProduct, 'The product with the same Merchant SKU is being listed now. SKU must be unique for each Amazon item.', Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
         }
         return true;
     }
     return false;
 }
 private function getActualListingType(Ess_M2ePro_Model_Listing_Product $listingProduct, array $change)
 {
     $validEbayValues = array(Ess_M2ePro_Model_Ebay_Listing_Product_Action_Request_Selling::LISTING_TYPE_AUCTION, Ess_M2ePro_Model_Ebay_Listing_Product_Action_Request_Selling::LISTING_TYPE_FIXED);
     if (isset($change['listingType']) && in_array($change['listingType'], $validEbayValues)) {
         switch ($change['listingType']) {
             case Ess_M2ePro_Model_Ebay_Listing_Product_Action_Request_Selling::LISTING_TYPE_AUCTION:
                 $result = Ess_M2ePro_Model_Ebay_Template_SellingFormat::LISTING_TYPE_AUCTION;
                 break;
             case Ess_M2ePro_Model_Ebay_Listing_Product_Action_Request_Selling::LISTING_TYPE_FIXED:
                 $result = Ess_M2ePro_Model_Ebay_Template_SellingFormat::LISTING_TYPE_FIXED;
                 break;
         }
     } else {
         $result = $listingProduct->getChildObject()->getListingType();
     }
     return $result;
 }
Ejemplo n.º 21
0
 private function checkSearchConditions(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     return $listingProduct->isNotListed() && !$amazonListingProduct->isGeneralIdOwner() && !$amazonListingProduct->getGeneralId();
 }
Ejemplo n.º 22
0
 protected function createNewAmazonItem(Ess_M2ePro_Model_Listing_Product $listingProduct, $sku)
 {
     $dataForAdd = array('account_id' => (int) $listingProduct->getListing()->getAccountId(), 'marketplace_id' => (int) $listingProduct->getListing()->getMarketplaceId(), 'sku' => $sku, 'product_id' => (int) $listingProduct->getProductId(), 'store_id' => (int) $listingProduct->getListing()->getStoreId());
     if ($listingProduct->getChildObject()->isVariationMatched() && $listingProduct->getChildObject()->isVariationProduct()) {
         $variations = $listingProduct->getVariations(true);
         /* @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
         $variation = reset($variations);
         $options = $variation->getOptions();
         $dataForAdd['variation_options'] = array();
         foreach ($options as $optionData) {
             $dataForAdd['variation_options'][$optionData['attribute']] = $optionData['option'];
         }
         $dataForAdd['variation_options'] = json_encode($dataForAdd['variation_options']);
     }
     return Mage::getModel('M2ePro/Amazon_Item')->setData($dataForAdd)->save()->getId();
 }
Ejemplo n.º 23
0
 /**
  * @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.º 24
0
 private function checkSearchConditions(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     return $listingProduct->isNotListed() && !$listingProduct->getChildObject()->getGeneralId();
 }
 private function prepareChangedListingsProducts(Ess_M2ePro_Model_Listing_Product $tempListingProductModel, $ebayChange)
 {
     /** @var $tempEbayListingProductModel Ess_M2ePro_Model_Ebay_Listing_Product */
     $tempEbayListingProductModel = $tempListingProductModel->getChildObject();
     // Prepare eBay changes values
     //--------------------------
     $tempEbayChanges = array();
     if ($tempEbayListingProductModel->isListingTypeAuction()) {
         $tempEbayChanges['online_start_price'] = (double) $ebayChange['currentPrice'] < 0 ? 0 : (double) $ebayChange['currentPrice'];
     }
     if ($tempEbayListingProductModel->isListingTypeFixed()) {
         $tempEbayChanges['online_buyitnow_price'] = (double) $ebayChange['currentPrice'] < 0 ? 0 : (double) $ebayChange['currentPrice'];
     }
     $tempEbayChanges['online_qty'] = (int) $ebayChange['quantity'] < 0 ? 0 : (int) $ebayChange['quantity'];
     $tempEbayChanges['online_qty_sold'] = (int) $ebayChange['quantitySold'] < 0 ? 0 : (int) $ebayChange['quantitySold'];
     if ($tempEbayListingProductModel->isListingTypeAuction()) {
         $tempEbayChanges['online_qty'] = 1;
         $tempEbayChanges['online_bids'] = (int) $ebayChange['bidCount'] < 0 ? 0 : (int) $ebayChange['bidCount'];
     }
     $tempEbayChanges['start_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($ebayChange['startTime']);
     $tempEbayChanges['end_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($ebayChange['endTime']);
     if ($tempEbayChanges['online_qty'] == $tempEbayChanges['online_qty_sold'] && ($ebayChange['listingStatus'] == self::EBAY_STATUS_COMPLETED || $ebayChange['listingStatus'] == self::EBAY_STATUS_ENDED)) {
         $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
     } else {
         if ($ebayChange['listingStatus'] == self::EBAY_STATUS_COMPLETED) {
             $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED;
         } else {
             if ($ebayChange['listingStatus'] == self::EBAY_STATUS_ENDED) {
                 $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED;
             } else {
                 if ($ebayChange['listingStatus'] == self::EBAY_STATUS_ACTIVE) {
                     $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_LISTED;
                 }
             }
         }
     }
     if ($tempListingProductModel->getStatus() != $tempEbayChanges['status'] || $tempListingProductModel->getChildObject()->getOnlineQty() != $tempEbayChanges['online_qty'] || $tempListingProductModel->getChildObject()->getOnlineQtySold() != $tempEbayChanges['online_qty_sold']) {
         Mage::getModel('M2ePro/ProductChange')->addUpdateAction($tempListingProductModel->getProductId(), Ess_M2ePro_Model_ProductChange::CREATOR_TYPE_SYNCHRONIZATION);
     }
     if ($tempEbayChanges['status'] != $tempListingProductModel->getStatus()) {
         $tempEbayChanges['status_changer'] = Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_COMPONENT;
         $tempLogMessage = '';
         switch ($tempEbayChanges['status']) {
             case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Listed".');
                 $tempLogMessage = 'Item status was successfully changed to "Listed".';
                 break;
             case Ess_M2ePro_Model_Listing_Product::STATUS_SOLD:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Sold".');
                 $tempLogMessage = 'Item status was successfully changed to "Sold".';
                 break;
             case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Stopped".');
                 $tempLogMessage = 'Item status was successfully changed to "Stopped".';
                 break;
             case Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED:
                 // Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Finished".');
                 $tempLogMessage = 'Item status was successfully changed to "Finished".';
                 break;
         }
         $tempLog = Mage::getModel('M2ePro/Listing_Log');
         $tempLog->setComponentMode(Ess_M2ePro_Helper_Component_Ebay::NICK);
         $tempLog->addProductMessage($tempListingProductModel->getListingId(), $tempListingProductModel->getProductId(), $tempListingProductModel->getId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_EXTENSION, $this->getLogActionId(), Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL, $tempLogMessage, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
     }
     //--------------------------
     // Create changed listings products
     //--------------------------
     $changedListingsProducts = array('ebay_item_id' => $ebayChange['id'], 'listing_product' => array('instance' => $tempListingProductModel, 'changes' => $tempEbayChanges), 'listings_products_variations' => array());
     //--------------------------
     // Cancel when have not eBay variations
     //--------------------------
     if (!isset($ebayChange['variations']) || is_null($ebayChange['variations'])) {
         return $changedListingsProducts;
     }
     //--------------------------
     // Get listings products variations
     //-----------------------
     $tempVariations = $tempListingProductModel->getVariations(true);
     if (count($tempVariations) == 0) {
         return $changedListingsProducts;
     }
     //-----------------------
     // Get listings products variations with options
     //-----------------------
     $tempVariationsWithOptions = array();
     foreach ($tempVariations as $variation) {
         /** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
         $options = $variation->getOptions(true);
         if (count($options) == 0) {
             continue;
         }
         $tempVariationsWithOptions[] = array('variation' => $variation, 'options' => $options);
     }
     if (count($tempVariationsWithOptions) == 0) {
         return $changedListingsProducts;
     }
     //-----------------------
     // Search our variations for eBay variations
     //--------------------------
     foreach ($ebayChange['variations'] as $ebayVariation) {
         // Find our variation
         //--------------------------
         foreach ($tempVariationsWithOptions as $M2eProVariation) {
             $equalVariation = true;
             foreach ($M2eProVariation['options'] as $M2eProOptionValue) {
                 $haveOption = false;
                 foreach ($ebayVariation['specifics'] as $ebayOptionKey => $ebayOptionValue) {
                     if ($M2eProOptionValue->getData('attribute') == $ebayOptionKey && $M2eProOptionValue->getData('option') == $ebayOptionValue) {
                         $haveOption = true;
                         break;
                     }
                 }
                 if ($haveOption === false) {
                     $equalVariation = false;
                     break;
                 }
             }
             if ($equalVariation === true && count($M2eProVariation['options']) == count($ebayVariation['specifics'])) {
                 // Prepare eBay changes values
                 //--------------------------
                 $tempEbayChanges = array();
                 $tempEbayChanges['online_price'] = (double) $ebayVariation['price'] < 0 ? 0 : (double) $ebayVariation['price'];
                 $tempEbayChanges['online_qty'] = (int) $ebayVariation['quantity'] < 0 ? 0 : (int) $ebayVariation['quantity'];
                 $tempEbayChanges['online_qty_sold'] = (int) $ebayVariation['quantitySold'] < 0 ? 0 : (int) $ebayVariation['quantitySold'];
                 if ($tempEbayChanges['online_qty'] <= $tempEbayChanges['online_qty_sold']) {
                     $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
                 }
                 if ($tempEbayChanges['online_qty'] <= 0) {
                     $tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED;
                 }
                 //--------------------------
                 // Add changed variation
                 //--------------------------
                 $changedListingsProducts['listings_products_variations'][] = array('instance' => $M2eProVariation, 'changes' => $tempEbayChanges);
                 //--------------------------
                 break;
             }
         }
         //--------------------------
     }
     return $changedListingsProducts;
 }
Ejemplo n.º 26
0
 protected function addDetailsData(Ess_M2ePro_Model_Listing_Product $listingProduct, array &$requestData)
 {
     $requestData['condition'] = $listingProduct->getChildObject()->getCondition();
     if (is_null($requestData['condition'])) {
         unset($requestData['condition']);
     } else {
         $requestData['condition_note'] = $listingProduct->getChildObject()->getConditionNote();
         if (is_null($requestData['condition_note'])) {
             unset($requestData['condition_note']);
         }
     }
 }
Ejemplo n.º 27
0
 protected function updateProduct(Ess_M2ePro_Model_Listing_Product $listingProduct, array $response)
 {
     $productData = array();
     $descriptionTemplate = $listingProduct->getChildObject()->getDescriptionTemplate();
     $oldDescriptionTemplateId = $descriptionTemplate->getId();
     if (!isset($this->descriptionTemplatesIds[$oldDescriptionTemplateId]) && (trim($descriptionTemplate->getData('title_template')) != '#ebay_translated_title#' || trim($descriptionTemplate->getData('subtitle_template')) != '#ebay_translated_subtitle#' || trim($descriptionTemplate->getData('description_template')) != '#ebay_translated_description#')) {
         $data = $descriptionTemplate->getDataSnapshot();
         unset($data['id'], $data['update_date'], $data['create_date']);
         $data['title'] = $data['title'] . Mage::helper('M2ePro')->__(' (Changed because Translation Service applied.)');
         $data['title_mode'] = Ess_M2ePro_Model_Ebay_Template_Description::TITLE_MODE_CUSTOM;
         $data['title_template'] = '#ebay_translated_title#';
         $data['subtitle_mode'] = Ess_M2ePro_Model_Ebay_Template_Description::SUBTITLE_MODE_CUSTOM;
         $data['subtitle_template'] = '#ebay_translated_subtitle#';
         $data['description_mode'] = Ess_M2ePro_Model_Ebay_Template_Description::DESCRIPTION_MODE_CUSTOM;
         $data['description_template'] = '#ebay_translated_description#';
         $data['is_custom_template'] = 1;
         $newDescriptionTemplate = Mage::getModel('M2ePro/Ebay_Template_Manager')->setTemplate(Ess_M2ePro_Model_Ebay_Template_Manager::TEMPLATE_DESCRIPTION)->getTemplateBuilder()->build($data);
         $this->descriptionTemplatesIds[$oldDescriptionTemplateId] = $newDescriptionTemplate->getId();
     }
     if (isset($this->descriptionTemplatesIds[$oldDescriptionTemplateId])) {
         $productData['template_description_custom_id'] = $this->descriptionTemplatesIds[$oldDescriptionTemplateId];
         $productData['template_description_mode'] = Ess_M2ePro_Model_Ebay_Template_Manager::MODE_CUSTOM;
     }
     $this->checkAndCreateMagentoAttributes(array('ebay_translated_title' => 'Ebay Translated Title', 'ebay_translated_subtitle' => 'Ebay Translated Subtitle'), 'text');
     $this->checkAndCreateMagentoAttributes(array('ebay_translated_description' => 'Ebay Translated Description'), 'textarea');
     $this->checkAndCreateMagentoProductAttributes($listingProduct->getMagentoProduct(), array('ebay_translated_title', 'ebay_translated_subtitle', 'ebay_translated_description'));
     $listingProduct->getMagentoProduct()->setAttributeValue('ebay_translated_title', $response['title'])->setAttributeValue('ebay_translated_subtitle', $response['subtitle'])->setAttributeValue('ebay_translated_description', $response['description']);
     //------------------------------
     $categoryPath = !is_null($response['category']['primary_id']) ? Mage::helper('M2ePro/Component_Ebay_Category_Ebay')->getPath((int) $response['category']['primary_id'], $this->params['marketplace_id']) : '';
     $response['category']['path'] = $categoryPath;
     if ($categoryPath) {
         $data = Mage::getModel('M2ePro/Ebay_Template_Category')->getDefaultSettings();
         $data['category_main_id'] = (int) $response['category']['primary_id'];
         $data['category_main_path'] = $categoryPath;
         $data['marketplace_id'] = $this->params['marketplace_id'];
         $data['specifics'] = $this->getSpecificsData($response['item_specifics']);
         $productData['template_category_id'] = Mage::getModel('M2ePro/Ebay_Template_Category_Builder')->build($data)->getId();
     } else {
         $response['category']['primary_id'] = null;
     }
     $additionalData = $listingProduct->getAdditionalData();
     $additionalData['translation_service']['to'] = array_merge($additionalData['translation_service']['to'], $response);
     $productData['additional_data'] = json_encode($additionalData);
     $listingProduct->addData($productData)->save();
     $listingProduct->getChildObject()->addData(array('translation_status' => Ess_M2ePro_Model_Ebay_Listing_Product::TRANSLATION_STATUS_TRANSLATED, 'translated_date' => Mage::helper('M2ePro')->getCurrentGmtDate()))->save();
 }
 private function isSkuExistsInM2ePro($sku, Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     // check in 3rd party by account and marketplace
     $listingOtherCollection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing_Other')->addFieldToFilter('sku', $sku)->addFieldToFilter('account_id', $this->account->getId())->addFieldToFilter('marketplace_id', Ess_M2ePro_Helper_Component_Buy::MARKETPLACE_ID);
     if ($listingOtherCollection->getSize() > 0) {
         if ($listingProduct->getChildObject()->getBuyListing()->isGenerateSkuModeNo()) {
             $this->addListingsProductsLogsMessage($listingProduct, 'The same Reference ID was found among 3rd Party Listings. Reference ID must be unique the product to be listed.', Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
         }
         return true;
     }
     // check in M2ePro listings by account and marketplace
     $listingProductCollection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing_Product');
     $listingTable = Mage::getResourceModel('M2ePro/Listing')->getMainTable();
     $listingProductCollection->getSelect()->join(array('l' => $listingTable), '`main_table`.`listing_id` = `l`.`id`', array());
     $listingProductCollection->addFieldToFilter('sku', $sku)->addFieldToFilter('account_id', $this->account->getId())->addFieldToFilter('marketplace_id', Ess_M2ePro_Helper_Component_Buy::MARKETPLACE_ID);
     if ($listingProductCollection->getSize() > 0) {
         if ($listingProduct->getChildObject()->getBuyListing()->isGenerateSkuModeNo()) {
             // M2ePro_TRANSLATIONS
             // The same Reference ID was found among M2E Listings. Reference ID must be unique the product to be listed.
             $this->addListingsProductsLogsMessage($listingProduct, 'The same Reference ID was found among M2E Listings. Reference ID must be unique the product to be listed.', Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
         }
         return true;
     }
     // check in queue of SKUs by account and marketplace
     $queue = $this->getQueueOfSkus();
     if (in_array($sku, $queue, true) || isset($this->skusToCheck[$sku])) {
         if ($listingProduct->getChildObject()->getBuyListing()->isGenerateSkuModeNo()) {
             $this->addListingsProductsLogsMessage($listingProduct, 'The product with the same Reference ID is being listed now. Reference ID must be unique the product to be listed.', Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 29
0
 protected function updateProductAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array(), $ebayItemsId = NULL, $saveEbayQtySold = false)
 {
     $dataForUpdate = array('status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED);
     !is_null($ebayItemsId) && ($dataForUpdate['ebay_item_id'] = (int) $ebayItemsId);
     isset($params['status_changer']) && ($dataForUpdate['status_changer'] = (int) $params['status_changer']);
     if (isset($params['start_date_raw'])) {
         $dataForUpdate['start_date'] = Ess_M2ePro_Model_Connector_Server_Ebay_Abstract::ebayTimeToString($params['start_date_raw']);
     }
     if (isset($params['end_date_raw'])) {
         $dataForUpdate['end_date'] = Ess_M2ePro_Model_Connector_Server_Ebay_Abstract::ebayTimeToString($params['end_date_raw']);
     }
     if ($saveEbayQtySold) {
         $dataForUpdate['online_qty_sold'] = is_null($listingProduct->getChildObject()->getOnlineQtySold()) ? 0 : $listingProduct->getChildObject()->getOnlineQtySold();
         $tempIsVariation = $nativeRequestData['is_variation_item'] && isset($nativeRequestData['variation']);
         $tempUpdateFlag = $tempIsVariation || isset($nativeRequestData['qty']);
         if ($tempUpdateFlag) {
             $tempQty = $tempIsVariation ? $listingProduct->getChildObject()->getQty() : $nativeRequestData['qty'];
             $dataForUpdate['online_qty'] = (int) $tempQty + (int) $dataForUpdate['online_qty_sold'];
         }
     } else {
         $dataForUpdate['online_qty_sold'] = 0;
         $tempIsVariation = $nativeRequestData['is_variation_item'] && isset($nativeRequestData['variation']);
         $tempUpdateFlag = $tempIsVariation || isset($nativeRequestData['qty']);
         if ($tempUpdateFlag) {
             $tempQty = $tempIsVariation ? $listingProduct->getChildObject()->getQty() : $nativeRequestData['qty'];
             $dataForUpdate['online_qty'] = $tempQty;
         }
     }
     if ($listingProduct->getChildObject()->isListingTypeFixed()) {
         $dataForUpdate['online_start_price'] = NULL;
         $dataForUpdate['online_reserve_price'] = NULL;
         $dataForUpdate['online_bids'] = NULL;
         $tempIsVariation = $nativeRequestData['is_variation_item'] && isset($nativeRequestData['variation']);
         $tempUpdateFlag = $tempIsVariation || isset($nativeRequestData['price_fixed']);
         if ($tempUpdateFlag) {
             if ($tempIsVariation) {
                 $tempPrice = NULL;
                 foreach ($nativeRequestData['variation'] as $variation) {
                     if ((int) $variation['qty'] <= 0) {
                         continue;
                     }
                     if (!is_null($tempPrice) && (double) $variation['price'] >= $tempPrice) {
                         continue;
                     }
                     $tempPrice = (double) $variation['price'];
                 }
             } else {
                 $tempPrice = $nativeRequestData['price_fixed'];
             }
             $dataForUpdate['online_buyitnow_price'] = (double) $tempPrice;
         }
     } else {
         $dataForUpdate['online_bids'] = 0;
         if (isset($nativeRequestData['price_start'])) {
             $dataForUpdate['online_start_price'] = (double) $nativeRequestData['price_start'];
         }
         if (isset($nativeRequestData['price_reserve'])) {
             $dataForUpdate['online_reserve_price'] = (double) $nativeRequestData['price_reserve'];
         }
         if (isset($nativeRequestData['price_buyitnow'])) {
             $dataForUpdate['online_buyitnow_price'] = (double) $nativeRequestData['price_buyitnow'];
         }
     }
     $listingProduct->addData($dataForUpdate)->save();
 }
Ejemplo n.º 30
0
 private function isScheduleThroughNow(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $dateEnd = $listingProduct->getChildObject()->getEndDate();
     if (is_null($dateEnd) || $dateEnd == '') {
         return false;
     }
     $interval = 60;
     $metric = $listingProduct->getSynchronizationTemplate()->getChildObject()->getRelistScheduleThroughMetric();
     $value = (int) $listingProduct->getSynchronizationTemplate()->getChildObject()->getRelistScheduleThroughValue();
     if ($metric == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_SCHEDULE_THROUGH_METRIC_DAYS) {
         $interval = 60 * 60 * 24;
     }
     if ($metric == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_SCHEDULE_THROUGH_METRIC_HOURS) {
         $interval = 60 * 60;
     }
     if ($metric == Ess_M2ePro_Model_Amazon_Template_Synchronization::RELIST_SCHEDULE_THROUGH_METRIC_MINUTES) {
         $interval = 60;
     }
     $interval = $interval * $value;
     $dateEnd = strtotime($dateEnd);
     if (Mage::helper('M2ePro')->getCurrentGmtDate(true) < $dateEnd + $interval) {
         return false;
     }
     return true;
 }