public function isExistProductAction(Ess_M2ePro_Model_Listing_Product $listingProductInstance, $action, array $params = array()) { $newListingsProductId = $listingProductInstance->getId(); $params['status_changer'] = Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_SYNCH; if (!isset($this->_actionsProducts[$newListingsProductId])) { return false; } if ($this->_actionsProducts[$newListingsProductId]['action'] != $action) { return false; } $tempExistItem = $this->_actionsProducts[$newListingsProductId]; foreach ($params as $tempParamKey => $tempParamValue) { if (!isset($tempExistItem['params'][$tempParamKey])) { return false; } if (is_array($tempExistItem['params'][$tempParamKey]) && is_array($tempParamValue)) { foreach ($tempParamValue as $tempParamKeyTwo => $tempParamValueTwo) { if (!isset($tempExistItem['params'][$tempParamKey][$tempParamKeyTwo])) { return false; } if ($tempExistItem['params'][$tempParamKey][$tempParamKeyTwo] != $tempParamValueTwo) { return false; } } continue; } if ($tempExistItem['params'][$tempParamKey] != $tempParamValue) { return false; } } return true; }
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(); } }
public function updateAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct) { if ($listingProduct->getMagentoProduct()->isProductWithoutVariations()) { return; } // TODO next release }
public function process() { $dispatcherObject = Mage::getModel('M2ePro/Connector_Buy_Dispatcher'); $connectorObj = $dispatcherObject->getConnector('custom', 'byQuery', 'requester', $this->getConnectorParams(), $this->listingProduct->getAccount(), 'Ess_M2ePro_Model_Buy_Search'); $searchData = $dispatcherObject->process($connectorObj); return $this->prepareResult($searchData); }
private function setListAttemptData(Ess_M2ePro_Model_Listing_Product $listingProduct) { $additionalData = $listingProduct->getAdditionalData(); $additionalData['last_list_attempt_date'] = Mage::helper('M2ePro')->getCurrentGmtDate(); $listingProduct->setSettings('additional_data', $additionalData); $listingProduct->save(); }
public function logListingProductMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, array $messageData, $priority = Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM) { if ($this->storeMode) { $this->storedMessages[] = array('type' => $this->initLogType($messageData[Ess_M2ePro_Model_Connector_Protocol::MESSAGE_TYPE_KEY]), 'text' => $messageData[Ess_M2ePro_Model_Connector_Protocol::MESSAGE_TEXT_KEY]); return; } $this->getListingLog()->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), $this->initiator, $this->actionId, $this->action, $messageData[Ess_M2ePro_Model_Connector_Protocol::MESSAGE_TEXT_KEY], $this->initLogType($messageData[Ess_M2ePro_Model_Connector_Protocol::MESSAGE_TYPE_KEY]), $priority); }
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))); }
protected function processAddedListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct, array $params) { if (!empty($params['template_category_id'])) { $listingProduct->setData('template_category_id', $params['template_category_id']); } if (!empty($params['template_other_category_id'])) { $listingProduct->setData('template_other_category_id', $params['template_other_category_id']); } $listingProduct->save(); }
protected function getSuccessfulParams(Ess_M2ePro_Model_Listing_Product $listingProduct, $response) { foreach ($response['skus'] as $key => $generalId) { if ((int) $key != (int) $listingProduct->getId()) { continue; } return array('general_id' => $generalId); } return array(); }
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(); }
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(); } }
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(); }
protected function getSuccessfulParams(Ess_M2ePro_Model_Listing_Product $listingProduct, $response) { if (!is_array($response['asins']) || empty($response['asins'])) { return array(); } foreach ($response['asins'] as $key => $asin) { if ((int) $key != (int) $listingProduct->getId()) { continue; } return array('general_id' => $asin); } return array(); }
public function getSpecifics(Ess_M2ePro_Model_Listing_Product $listingProduct) { $attributeCode = Mage::helper('M2ePro/Module')->getConfig()->getGroupValue('/ebay/motor/', 'motors_specifics_attribute'); if (empty($attributeCode)) { return false; } $attributeValue = $listingProduct->getMagentoProduct()->getAttributeValue($attributeCode); if (empty($attributeValue)) { return array(); } $epids = explode(self::VALUE_SEPARATOR, $attributeValue); return Mage::getModel('M2ePro/Ebay_Motor_Specific')->getCollection()->addFieldToFilter('epid', array('in' => $epids))->getItems(); }
public function process(Ess_M2ePro_Model_Listing_Product $listingProduct, $query) { $searchMethod = 'byQuery'; $tempQuery = str_replace('-', '', $query); if ($this->isQueryEan($tempQuery) || $this->isQueryIsbn($tempQuery)) { $query = $tempQuery; $searchMethod = 'byEanIsbn'; } $params = array('query' => $query, 'type' => 'manual', 'listing_product_id' => $listingProduct->getId()); Mage::getModel('M2ePro/Connector_Play_Dispatcher')->processConnector('search', $searchMethod, 'requester', $params, $listingProduct->getAccount(), 'Ess_M2ePro_Model_Play'); $result = Mage::helper('M2ePro/Data_Global')->getValue('temp_play_manual_search_result'); Mage::helper('M2ePro/Data_Global')->unsetValue('temp_play_manual_search_result'); return $result; }
public function process(Ess_M2ePro_Model_Listing_Product $listingProduct, $query) { $searchMethod = 'byQuery'; if ($this->isQueryGeneralId($query) || $this->isQueryUpc($query)) { $searchMethod = 'byIdentifier'; } $params = array('query' => $query, 'type' => 'manual', 'listing_product_id' => $listingProduct->getId()); if ($searchMethod == 'byIdentifier') { $params['search_type'] = $this->getSearchType($query); } Mage::getModel('M2ePro/Connector_Buy_Dispatcher')->processConnector('search', $searchMethod, 'requester', $params, $listingProduct->getAccount(), 'Ess_M2ePro_Model_Buy'); $result = Mage::helper('M2ePro/Data_Global')->getValue('temp_buy_manual_search_result'); Mage::helper('M2ePro/Data_Global')->unsetValue('temp_buy_manual_search_result'); return $result; }
protected function isChangeInitiatorOnlyInspector(Ess_M2ePro_Model_Listing_Product $listingProduct) { $changeInitiators = $listingProduct->getData('change_initiators'); if (empty($changeInitiators)) { return false; } $changeInitiators = (array) explode(',', $changeInitiators); $changeInitiators = array_unique($changeInitiators); if (count($changeInitiators) != 1) { return false; } if ((int) reset($changeInitiators) != Ess_M2ePro_Model_ProductChange::INITIATOR_INSPECTOR) { return false; } return true; }
private function getItemDataByListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct) { $connectorClassName = 'Ess_M2ePro_Model_Connector_Server_' . ucfirst($listingProduct->getComponentMode()) . '_'; $connectorClassName .= $listingProduct->isComponentModeEbay() ? 'Item' : 'Product'; $connectorClassName .= '_Stop_Multiple'; try { $connector = new $connectorClassName(array(), array($listingProduct)); $itemData = $connector->getRequestDataPackage(); } catch (Exception $exception) { return NULL; } if (!isset($itemData['data']['items'])) { return NULL; } return array_shift($itemData['data']['items']); }
private function processItem(Ess_M2ePro_Model_Listing_Product $listingProduct) { if ($listingProduct->isNotListed()) { $this->isMeetListRequirements($listingProduct) && $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_LIST, array()); } else { if ($listingProduct->isListed()) { if ($this->isMeetStopRequirements($listingProduct)) { $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_STOP, array()); return; } $this->inspectReviseQtyRequirements($listingProduct); $this->inspectRevisePriceRequirements($listingProduct); } else { $this->isMeetRelistRequirements($listingProduct) && $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_RELIST, array()); } } }
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; }
private function getItemDataByListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct) { $connectorClassName = 'Ess_M2ePro_Model_Connector_' . ucfirst($listingProduct->getComponentMode()) . '_'; $connectorClassName .= $listingProduct->isComponentModeEbay() ? 'Item' : 'Product'; $connectorClassName .= '_Stop_Multiple' . ($listingProduct->isComponentModeEbay() ? '' : 'Requester'); $connectorParams = array('logs_action_id' => 0, 'status_changer' => Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_UNKNOWN); try { $connector = new $connectorClassName($connectorParams, array($listingProduct)); $itemData = $connector->getRequestDataPackage(); } catch (Exception $exception) { return NULL; } if (!isset($itemData['data']['items'])) { return NULL; } return array_shift($itemData['data']['items']); }
private function getSearchType() { /* @var $listing Ess_M2ePro_Model_Buy_Listing */ $listing = $this->listingProduct->getListing()->getChildObject(); $searchType = false; if ($listing->isGeneralIdGeneralIdMode()) { $searchType = 'sku'; } return $searchType; }
public function process(Ess_M2ePro_Model_Listing_Product $listingProduct, $query) { $searchMethod = 'byQuery'; $validation = Mage::helper('M2ePro'); $tempQuery = str_replace('-', '', $query); if (Mage::helper('M2ePro/Component_Amazon')->isASIN($tempQuery) || $validation->isISBN10($tempQuery)) { $query = $tempQuery; $searchMethod = 'byAsin'; } elseif ($validation->isEAN($tempQuery) || $validation->isUPC($tempQuery) || $validation->isISBN13($tempQuery)) { $query = $tempQuery; $searchMethod = 'byIdentifier'; } $params = array('item' => $query, 'type' => 'manual', 'only_realtime' => true, 'search_method' => $searchMethod, 'listing_product_id' => $listingProduct->getId()); if ($searchMethod == 'byIdentifier') { $params['id_type'] = $this->getIdentifierType($query); } Mage::getModel('M2ePro/Connector_Amazon_Dispatcher')->processConnector('search', $searchMethod, 'requester', $params, $listingProduct->getAccount(), 'Ess_M2ePro_Model_Amazon'); $result = Mage::helper('M2ePro/Data_Global')->getValue('temp_amazon_manual_search_result'); Mage::helper('M2ePro/Data_Global')->unsetValue('temp_amazon_manual_search_result'); return $result; }
public function getRequestData() { /** @var $listing Ess_M2ePro_Model_Buy_Listing */ $listing = $this->listingProduct->getListing()->getChildObject(); $searchType = false; if ($listing->isGeneralIdGeneralIdMode()) { $searchType = Ess_M2ePro_Model_Connector_Server_Buy_Search_Items::SEARCH_TYPE_GENERAL_ID; } if ($listing->isGeneralIdWorldwideMode()) { $searchType = Ess_M2ePro_Model_Connector_Server_Buy_Search_Items::SEARCH_TYPE_UPC; } return $searchType ? array('search_type' => $searchType) : array(); }
protected function filterReceivedItemsFullTitleMatch($receivedItems) { $return = array(); $magentoProductTitle = $this->listingProduct->getMagentoProduct()->getName(); $magentoProductTitle = trim(strtolower($magentoProductTitle)); foreach ($receivedItems as $item) { $itemTitle = trim(strtolower($item['title'])); if ($itemTitle == $magentoProductTitle) { $return[] = $item; } } return $return; }
private function getSearchType() { /* @var $listing Ess_M2ePro_Model_Buy_Listing */ $listing = $this->listingProduct->getListing()->getChildObject(); $searchType = false; if ($listing->isGeneralIdGeneralIdMode()) { $searchType = Ess_M2ePro_Model_Connector_Buy_Search_ByIdentifier_ItemsRequester::SEARCH_TYPE_GENERAL_ID; } if ($listing->isGeneralIdWorldwideMode()) { $searchType = Ess_M2ePro_Model_Connector_Buy_Search_ByIdentifier_ItemsRequester::SEARCH_TYPE_UPC; } return $searchType; }
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); }
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(); }
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(); }
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); }