Example #1
0
 public function process()
 {
     if (is_null($this->listingProduct)) {
         throw new \Ess\M2ePro\Model\Exception('Listing Product was not set.');
     }
     $this->getTypeModel()->enableCache();
     foreach ($this->getSortedProcessors() as $processor) {
         $this->getProcessorModel($processor)->process();
     }
     $this->listingProduct->getChildObject()->setData('variation_parent_need_processor', 0);
     $this->listingProduct->save();
 }
Example #2
0
 protected function markAsPotentialDuplicate()
 {
     $additionalData = $this->listingProduct->getAdditionalData();
     $additionalData['last_failed_action_data'] = array('native_request_data' => $this->getRequestDataObject()->getData(), 'previous_status' => $this->listingProduct->getStatus(), 'action' => $this->getActionType(), 'request_time' => $this->getResponse()->getRequestTime());
     $this->listingProduct->addData(array('status' => \Ess\M2ePro\Model\Listing\Product::STATUS_BLOCKED, 'additional_data' => json_encode($additionalData)))->save();
     $this->listingProduct->getChildObject()->updateVariationsStatus();
 }
Example #3
0
 private function getConnectorParams()
 {
     $searchMethod = $this->getSearchMethod();
     /** @var \Ess\M2ePro\Model\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;
 }
Example #4
0
 protected function processAddedListingProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct, array $params)
 {
     $ebayListingProduct = $listingProduct->getChildObject();
     if (!empty($params['template_category_id'])) {
         $ebayListingProduct->setData('template_category_id', $params['template_category_id']);
     }
     if (!empty($params['template_other_category_id'])) {
         $ebayListingProduct->setData('template_other_category_id', $params['template_other_category_id']);
     }
     $listingProduct->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'])) {
         $message = $this->modelFactory->getObject('Connector\\Connection\\Response\\Message');
         $message->initFromPreparedData('Unexpected error. The ASIN/ISBN for Parent or Child Product was not returned from Amazon.
              Operation cannot be finished correctly.', \Ess\M2ePro\Model\Connector\Connection\Response\Message::TYPE_ERROR);
         $this->getLogger()->logListingProductMessage($listingProduct, $message, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_MEDIUM);
         return;
     }
     parent::processSuccess($listingProduct, $params);
 }
Example #6
0
 private function duplicateListingProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     $duplicatedListingProduct = $listingProduct->getListing()->addProduct($listingProduct->getProductId(), false, false);
     $variationManager = $listingProduct->getChildObject()->getVariationManager();
     if (!$variationManager->isVariationProduct()) {
         return $duplicatedListingProduct;
     }
     if ($listingProduct->isComponentModeAmazon()) {
         $duplicatedListingProductManager = $duplicatedListingProduct->getChildObject()->getVariationManager();
         if ($variationManager->isIndividualType() && $duplicatedListingProductManager->modeCanBeSwitched()) {
             $duplicatedListingProductManager->switchModeToAnother();
         }
     }
     return $duplicatedListingProduct;
 }
Example #7
0
 private function checkVariationStructureChanges(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager $variationManager */
     $variationManager = $listingProduct->getChildObject()->getVariationManager();
     if ($variationManager->isRelationParentType()) {
         $this->parentListingsProductsForProcessing[$listingProduct->getId()] = $listingProduct;
         return;
     }
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager\PhysicalUnit $typeModel */
     $typeModel = $variationManager->getTypeModel();
     if (!$listingProduct->getMagentoProduct()->isSimpleType()) {
         $typeModel->inspectAndFixProductOptionsIds();
     }
     if (!$typeModel->isActualProductAttributes()) {
         if ($variationManager->isRelationChildType()) {
             $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\ChildRelation $typeModel */
             $this->parentListingsProductsForProcessing[$typeModel->getParentListingProduct()->getId()] = $typeModel->getParentListingProduct();
             return;
         }
         $typeModel->unsetProductVariation();
     }
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager\Type\Relation\ChildRelation $typeModel */
     if ($variationManager->isRelationChildType() && $typeModel->getParentTypeModel()->getVirtualChannelAttributes()) {
         if (!$typeModel->getParentTypeModel()->isActualVirtualChannelAttributes()) {
             $this->parentListingsProductsForProcessing[$typeModel->getParentListingProduct()->getId()] = $typeModel->getParentListingProduct();
         }
     }
 }
Example #8
0
 private function matchEmptyChannelOptionsChild(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product\Variation\Manager\Type\Relation\ChildRelation $typeModel */
     $typeModel = $listingProduct->getChildObject()->getVariationManager()->getTypeModel();
     $channelOptions = array_merge($this->getProcessor()->getTypeModel()->getUnusedChannelOptions(), $this->getProcessor()->getTypeModel()->getUsedChannelOptions(true));
     if (empty($channelOptions)) {
         return;
     }
     if (!$typeModel->isVariationProductMatched()) {
         return;
     }
     $matcher = $this->getOptionMatcher();
     $matcher->setDestinationOptions($channelOptions);
     $generalId = $matcher->getMatchedOptionGeneralId($typeModel->getProductOptions());
     if (is_null($generalId)) {
         return;
     }
     $existChild = $this->findChildByChannelOptions($channelOptions[$generalId]);
     if (!is_null($existChild)) {
         $this->getProcessor()->tryToRemoveChildListingProduct($existChild);
     }
     $listingProduct->getChildObject()->setData('general_id', $generalId);
     $typeModel->setChannelVariation($channelOptions[$generalId]);
 }
 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'] . $this->getHelper('Module\\Translation')->__(' (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 = $this->modelFactory->getObject('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;
     }
     $attributes = array('ebay_translated_title' => array('label' => 'Ebay Translated Title', 'type' => 'text'), 'ebay_translated_subtitle' => array('label' => 'Ebay Translated Subtitle', 'type' => 'text'), 'ebay_translated_description' => array('label' => 'Ebay Translated Description', 'type' => 'textarea'));
     $this->checkAndCreateMagentoAttributes($listingProduct->getMagentoProduct(), $attributes);
     $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']) ? $this->getHelper('Component\\Ebay\\Category\\Ebay')->getPath((int) $response['category']['primary_id'], $this->params['marketplace_id']) : '';
     $response['category']['path'] = $categoryPath;
     if ($categoryPath) {
         $data = $this->activeRecordFactory->getObject('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'] = $this->modelFactory->getObject('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' => $this->getHelper('Data')->getCurrentGmtDate()))->save();
 }
Example #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_RELIST) {
         $configurator->setParams(array('replaced_action' => \Ess\M2ePro\Model\Listing\Product::ACTION_RELIST));
     }
     /** @var \Ess\M2ePro\Model\Ebay\Listing\Product $ebayListingProduct */
     $ebayListingProduct = $listingProduct->getChildObject();
     if (!$ebayListingProduct->getEbaySynchronizationTemplate()->isRelistSendData()) {
         $configurator->setPartialMode();
         $configurator->allowQty()->allowPrice()->allowVariations();
     }
 }
Example #11
0
    public function callbackColumnActions($value, $row, $column, $isExport)
    {
        $assignText = $this->__('Assign');
        $iconWarningPath = $this->getSkinUrl('M2ePro/images/warning.png');
        $iconHelpPath = $this->getSkinUrl('M2ePro/images/i_notice.gif');
        if (!$this->listingProduct->getChildObject()->getVariationManager()->isVariationProduct() || $this->listingProduct->getChildObject()->getVariationManager()->isIndividualType()) {
            if (!$row->getData('is_variation_product')) {
                return <<<HTML
<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId(
    {$this->productId}, '{$row->getData('general_id')}');">{$assignText}</a>
HTML;
            }
            if (!$row->getData('bad_parent')) {
                $msg = $this->__('Please select necessary Options for this Amazon Product to be able to assign ASIN/ISBN.');
                return <<<HTML
<span>
    <span id="map_link_{$row->getId()}"><span style="color: #808080">{$assignText}</span></span>&nbsp;
    {$this->getTooltipHtml($msg, 'map_link_error_icon_' . $row->getId())}
</span>
<div id="template_map_link_{$row->getId()}" style="display: none;">
<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId(
    {$this->productId}, '%general_id%', '%options_data%'
);">{$assignText}</a>
</div>
HTML;
            }
        }
        if ($row->getData('is_variation_product') && !$row->getData('bad_parent')) {
            $msg = $this->__('Please map Amazon and Magento Attributes for this Amazon Product to be able to assign ASIN/ISBN.');
            $variations = $row->getData('variations');
            $destinationAttributes = array_keys($variations['set']);
            $this->matcherAttributes->setMagentoProduct($this->listingProduct->getMagentoProduct());
            $this->matcherAttributes->setDestinationAttributes($destinationAttributes);
            if ($this->matcherAttributes->isSourceAmountGreater()) {
                $msg = $this->__('Please map Magento and Amazon Attributes for this Amazon Product to be able to assign ASIN/ISBN.
                    Be careful, as the number of  Magento Attributes is more than the number of Attributes in Amazon
                    Parent Product. Thus you should select fixed Value for unmatched Magento Variational Attribute.');
            } else {
                if ($this->matcherAttributes->isDestinationAmountGreater()) {
                    $msg = $this->__('Please map Magento and Amazon Attributes for this Amazon Product to be able to assign ASIN/ISBN.
                    Be careful, as the number of Attributes in Amazon Parent Product is more than the number of
                    Magento Attributes. Thus you should select fixed Value for unmatched Amazon Variational Attribute.');
                }
            }
            return <<<HTML
<span>
    <div id="map_link_{$row->getId()}"><span style="color: #808080">{$assignText}</span></div>&nbsp;
    {$this->getTooltipHtml($msg, 'map_link_error_icon_' . $row->getId())}
</span>
<div id="template_map_link_{$row->getId()}" style="display: none;">
<a href="javascript:void(0);" onclick="ListingGridHandlerObj.productSearchHandler.mapToGeneralId(
    {$this->productId}, '{$row->getData('general_id')}', '%options_data%'
);">{$assignText}</a>
</div>
HTML;
        }
        $msg = $this->__('This ASIN/ISBN cannot be assigned to selected Magento Product. <br/>
             This Amazon Product has no Variations. <br/>
             Only Amazon Parent/Child Products can be assigned in "All Variations" Mode.');
        if ($row->getData('is_variation_product') && $row->getData('bad_parent')) {
            $msg = $this->__('This ASIN/ISBN cannot be assigned to selected Magento Product. <br/>
                 Amazon Service (API) does not return all required information about this Amazon Product.');
        }
        return <<<HTML
<span>
    <span id="map_link_{$row->getId()}"><span style="color: #808080">{$assignText}</span></span>&nbsp;
    {$this->getTooltipHtml($msg, 'map_link_error_icon_' . $row->getId())}
</span>
HTML;
    }
Example #12
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->isOutOfStockControlEnabled() && $action == \Ess\M2ePro\Model\Listing\Product::ACTION_STOP) {
         return;
     }
     $configurator->setPartialMode();
     $configurator->allowQty()->allowVariations();
 }
 private function modifyAndLogListingProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct, $status, $duplicateItemId = null)
 {
     /** @var \Ess\M2ePro\Model\Listing\Log $logModel */
     $logModel = $this->activeRecordFactory->getObject('Listing\\Log');
     $logModel->setComponentMode(\Ess\M2ePro\Helper\Component\Ebay::NICK);
     $logsActionId = $logModel->getNextActionId();
     $statusLogMessage = $this->getStatusLogMessage($listingProduct->getStatus(), $status);
     $logModel->addProductMessage($listingProduct->getData('listing_id'), $listingProduct->getData('product_id'), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, $logsActionId, \Ess\M2ePro\Model\Listing\Log::ACTION_CHANNEL_CHANGE, $statusLogMessage, \Ess\M2ePro\Model\Log\AbstractLog::TYPE_SUCCESS, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
     $additionalData = $listingProduct->getAdditionalData();
     unset($additionalData['last_failed_action_data']);
     $listingProduct->addData(array('status' => $status, 'additional_data' => json_encode($additionalData)))->save();
     $listingProduct->getChildObject()->updateVariationsStatus();
     if (is_null($duplicateItemId)) {
         return;
     }
     // M2ePro\TRANSLATIONS
     // Duplicated Item %item_id% was found and Stopped on eBay.
     $textToTranslate = 'Duplicated Item %item_id% was found and stopped on eBay.';
     $duplicateDeletedMessage = $this->getHelper('Module\\Translation')->__($textToTranslate, $duplicateItemId);
     $logModel->addProductMessage($listingProduct->getData('listing_id'), $listingProduct->getData('product_id'), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, $logsActionId, \Ess\M2ePro\Model\Listing\Log::ACTION_CHANNEL_CHANGE, $duplicateDeletedMessage, \Ess\M2ePro\Model\Log\AbstractLog::TYPE_WARNING, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
 }
Example #14
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;
     }
     if ($listingProduct->isSetProcessingLock('in_action')) {
         return false;
     }
     return true;
 }
Example #15
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();
 }
Example #16
0
 protected function processAddedListingProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct, array $params)
 {
     if (empty($params['template_description_id'])) {
         return;
     }
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     if (!$amazonListingProduct->getVariationManager()->isRelationParentType()) {
         $amazonListingProduct->setData('template_description_id', $params['template_description_id']);
         $amazonListingProduct->setData('is_general_id_owner', \Ess\M2ePro\Model\Amazon\Listing\Product::IS_GENERAL_ID_OWNER_YES);
         $listingProduct->save();
         return;
     }
     $processor = $amazonListingProduct->getVariationManager()->getTypeModel()->getProcessor();
     if ($listingProduct->getMagentoProduct()->isBundleType() || $listingProduct->getMagentoProduct()->isSimpleTypeWithCustomOptions()) {
         $processor->process();
         return;
     }
     $detailsModel = $this->modelFactory->getObject('Amazon\\Marketplace\\Details');
     $detailsModel->setMarketplaceId($listingProduct->getListing()->getMarketplaceId());
     /** @var \Ess\M2ePro\Model\Template\Description $descriptionTemplate */
     $descriptionTemplate = $this->amazonFactory->getObjectLoaded('Template\\Description', $params['template_description_id']);
     /** @var \Ess\M2ePro\Model\Amazon\Template\Description $amazonDescriptionTemplate */
     $amazonDescriptionTemplate = $descriptionTemplate->getChildObject();
     $possibleThemes = $detailsModel->getVariationThemes($amazonDescriptionTemplate->getProductDataNick());
     $productAttributes = $amazonListingProduct->getVariationManager()->getTypeModel()->getProductAttributes();
     foreach ($possibleThemes as $theme) {
         if (count($theme['attributes']) != count($productAttributes)) {
             continue;
         }
         $amazonListingProduct->setData('template_description_id', $params['template_description_id']);
         $amazonListingProduct->setData('is_general_id_owner', \Ess\M2ePro\Model\Amazon\Listing\Product::IS_GENERAL_ID_OWNER_YES);
         break;
     }
     $listingProduct->save();
     $processor->process();
 }
Example #17
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Product $listingProduct
  * @return bool
  * @throws \Ess\M2ePro\Model\Exception\Logic
  */
 public function isMeetRevisePriceRequirements(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     if (!$this->isMeetReviseGeneralRequirements($listingProduct)) {
         return false;
     }
     if ($this->getHelper('Component\\Amazon\\Repricing')->isEnabled() && $amazonListingProduct->isRepricing()) {
         return false;
     }
     $amazonSynchronizationTemplate = $amazonListingProduct->getAmazonSynchronizationTemplate();
     if (!$amazonSynchronizationTemplate->isReviseWhenChangePrice()) {
         return false;
     }
     $currentPrice = $amazonListingProduct->getPrice();
     $onlinePrice = $amazonListingProduct->getOnlinePrice();
     $needRevise = $this->checkRevisePricesRequirements($amazonSynchronizationTemplate, $onlinePrice, $currentPrice);
     if ($needRevise) {
         return true;
     }
     $currentSalePriceInfo = $amazonListingProduct->getSalePriceInfo();
     if ($currentSalePriceInfo !== false) {
         $currentSalePrice = $currentSalePriceInfo['price'];
         $currentSalePriceStartDate = $currentSalePriceInfo['start_date'];
         $currentSalePriceEndDate = $currentSalePriceInfo['end_date'];
     } else {
         $currentSalePrice = 0;
         $currentSalePriceStartDate = null;
         $currentSalePriceEndDate = null;
     }
     $onlineSalePrice = $amazonListingProduct->getOnlineSalePrice();
     if (!$currentSalePrice && !$onlineSalePrice) {
         return false;
     }
     if (is_null($currentSalePrice) && !is_null($onlineSalePrice) || !is_null($currentSalePrice) && is_null($onlineSalePrice)) {
         return true;
     }
     $needRevise = $this->checkRevisePricesRequirements($amazonSynchronizationTemplate, $onlineSalePrice, $currentSalePrice);
     if ($needRevise) {
         return true;
     }
     $onlineSalePriceStartDate = $amazonListingProduct->getOnlineSalePriceStartDate();
     $onlineSalePriceEndDate = $amazonListingProduct->getOnlineSalePriceEndDate();
     if ($currentSalePriceStartDate != $onlineSalePriceStartDate || $currentSalePriceEndDate != $onlineSalePriceEndDate) {
         return true;
     }
     return false;
 }
Example #18
0
 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;
 }