public function runManual(Ess_M2ePro_Model_Listing_Product $listingProduct, $query, Ess_M2ePro_Model_Marketplace $marketplace = NULL, Ess_M2ePro_Model_Account $account = NULL) { if (!$listingProduct->isNotListed() || empty($query)) { return false; } $params = array('listing_product' => $listingProduct, 'query' => $query); if (is_null($marketplace)) { $marketplace = $listingProduct->getGeneralTemplate()->getMarketplace(); } if (is_null($account)) { $account = $listingProduct->getGeneralTemplate()->getAccount(); } try { $dispatcherObject = Mage::getModel('M2ePro/Amazon_Connector')->getDispatcher(); $dispatcherObject->processConnector('search', 'manual', 'requester', $params, $marketplace, $account, 'Ess_M2ePro_Model_Amazon'); } catch (Exception $exception) { Mage::helper('M2ePro/Exception')->process($exception, true); return false; } $result = Mage::helper('M2ePro')->getGlobalValue('temp_amazon_manual_search_asin_result'); Mage::helper('M2ePro')->unsetGlobalValue('temp_amazon_manual_search_asin_result'); if (!is_array($result)) { return array(); } return $result; }
public function isAddedNewVariationsAttributes(Ess_M2ePro_Model_Listing_Product $listingProduct) { if (!$listingProduct->getChildObject()->isListingTypeFixed() || !$listingProduct->getGeneralTemplate()->getChildObject()->isVariationMode()) { return false; } return parent::isAddedNewVariationsAttributes($listingProduct); }
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(); }
protected function addInternationalTradeData(Ess_M2ePro_Model_Listing_Product $listingProduct, array &$requestData) { $requestData['international_trade'] = 'None'; $internationalTrade = $listingProduct->getGeneralTemplate()->getChildObject()->getSettings('international_trade'); if (!empty($internationalTrade)) { if (isset($internationalTrade['international_trade_uk']) && (int) $internationalTrade['international_trade_uk'] == 1) { $requestData['international_trade'] = 'UK'; } if (isset($internationalTrade['international_trade_na']) && (int) $internationalTrade['international_trade_na'] == 1) { $requestData['international_trade'] = 'North America'; } } }
public function updateAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array(), $saveEbayQtySold = false) { if (!$listingProduct->getChildObject()->isListingTypeFixed() || !$listingProduct->getGeneralTemplate()->getChildObject()->isVariationMode() || $listingProduct->getMagentoProduct()->isProductWithoutVariations()) { return; } // Delete Variations //----------------------------- $productVariations = $listingProduct->getVariations(true); foreach ($productVariations as $variation) { /** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */ $variation->isDelete() && $variation->deleteInstance(); } //----------------------------- // Update Variations //----------------------------- $productVariations = $listingProduct->getVariations(true); foreach ($productVariations as $variation) { /** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */ $dataForUpdate = array('online_price' => $variation->getChildObject()->getPrice(), 'add' => Ess_M2ePro_Model_Listing_Product_Variation::ADD_NO, 'delete' => Ess_M2ePro_Model_Listing_Product_Variation::DELETE_NO, 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED); if ($saveEbayQtySold) { $dataForUpdate['online_qty_sold'] = is_null($variation->getChildObject()->getOnlineQtySold()) ? 0 : $variation->getChildObject()->getOnlineQtySold(); $dataForUpdate['online_qty'] = $variation->getChildObject()->getQty() + $dataForUpdate['online_qty_sold']; } else { $dataForUpdate['online_qty_sold'] = 0; $dataForUpdate['online_qty'] = $variation->getChildObject()->getQty(); } if ($dataForUpdate['online_qty'] <= $dataForUpdate['online_qty_sold']) { $dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD; } if ($dataForUpdate['online_qty'] <= 0) { $dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED; } $variation->addData($dataForUpdate)->save(); } //----------------------------- }
private function isWorldWideIdAlreadyExists($worldwideId, Ess_M2ePro_Model_Listing_Product $listingProduct) { if (!$worldwideId) { return false; } $marketplaceObj = $listingProduct->getGeneralTemplate()->getMarketplace(); $accountObj = $listingProduct->getGeneralTemplate()->getAccount(); /** @var $dispatcher Ess_M2ePro_Model_Amazon_Search_Dispatcher */ $dispatcher = Mage::getModel('M2ePro/Amazon_Search_Dispatcher'); $results = $dispatcher->runManual($listingProduct, $worldwideId, $marketplaceObj, $accountObj); if (empty($results)) { return false; } return true; }