public function isExistProductAction(Ess_M2ePro_Model_Listing_Other $listingOtherInstance, $action, array $params = array()) { $newListingsOtherId = $listingOtherInstance->getId(); $params['status_changer'] = Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_SYNCH; if (!isset($this->_actionsProducts[$newListingsOtherId])) { return false; } if ($this->_actionsProducts[$newListingsOtherId]['action'] != $action) { return false; } $tempExistItem = $this->_actionsProducts[$newListingsOtherId]; 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; }
public function __construct(array $params = array(), Ess_M2ePro_Model_Listing_Other $otherListing) { $defaultParams = array('status_changer' => Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_UNKNOWN); $params = array_merge($defaultParams, $params); $this->otherListing = $otherListing; parent::__construct($params, $this->otherListing->getMarketplace(), $this->otherListing->getAccount(), NULL); }
public function logListingOtherMessage(Ess_M2ePro_Model_Listing_Other $listingOther, 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->getListingOtherLog()->addProductMessage($listingOther->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 isMeetStopRequirements(Ess_M2ePro_Model_Listing_Other $listingOther) { // eBay available status //-------------------- if (!$listingOther->isListed()) { return false; } if (!$listingOther->isStoppable()) { return false; } if (is_null($listingOther->getProductId())) { return false; } if ($this->_runnerActions->isExistProductAction($listingOther, Ess_M2ePro_Model_Connector_Server_Ebay_Item_Dispatcher::ACTION_STOP, array())) { return false; } //-------------------- // Correct synchronization //-------------------- if (!$listingOther->getAccount()->getChildObject()->isOtherListingsMappedSynchronizationEnabled()) { return false; } //-------------------- // Check filters //-------------------- if ($listingOther->getChildObject()->getSynchronizationModel()->isStopStatusDisabled()) { if ($listingOther->getMagentoProduct()->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) { return true; } } if ($listingOther->getChildObject()->getSynchronizationModel()->isStopOutOfStock()) { if (!$listingOther->getMagentoProduct()->getStockAvailability()) { return true; } } if ($listingOther->getChildObject()->getSynchronizationModel()->isStopWhenQtyHasValue()) { $productQty = $listingOther->getChildObject()->getMappedQty(); if (!is_null($productQty)) { /** @var $ebaySynchronizationTemplate Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization */ $ebaySynchronizationTemplate = $listingOther->getChildObject()->getSynchronizationModel(); $typeQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyHasValueType(); $minQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyHasValueMin(); $maxQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { return true; } } } //-------------------- return false; }
private function isMeetStopRequirements(Ess_M2ePro_Model_Listing_Other $listingOther) { // eBay available status //-------------------- if (!$listingOther->isListed()) { return false; } if (!$listingOther->isStoppable()) { return false; } if (is_null($listingOther->getProductId())) { return false; } if ($this->getRunner()->isExistProduct($listingOther, Ess_M2ePro_Model_Listing_Product::ACTION_STOP, array())) { return false; } //-------------------- /** @var $ebaySynchronizationTemplate Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization */ $ebaySynchronizationTemplate = $listingOther->getChildObject()->getSynchronizationModel(); // Correct synchronization //-------------------- if (!$ebaySynchronizationTemplate->isMode()) { return false; } //-------------------- // Check filters //-------------------- if ($ebaySynchronizationTemplate->isStopStatusDisabled()) { if (!$listingOther->getMagentoProduct()->isStatusEnabled()) { return true; } } if ($ebaySynchronizationTemplate->isStopOutOfStock()) { if (!$listingOther->getMagentoProduct()->isStockAvailability()) { return true; } } if ($ebaySynchronizationTemplate->isStopWhenQtyHasValue()) { $productQty = $listingOther->getChildObject()->getMappedQty(); if (!is_null($productQty)) { $typeQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyHasValueType(); $minQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyHasValueMin(); $maxQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) { return true; } if ($typeQty == Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { return true; } } } //-------------------- return false; }
public function __construct(array $params = array(), Ess_M2ePro_Model_Listing_Other $otherListing) { $defaultParams = array('status_changer' => Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_UNKNOWN); $params = array_merge($defaultParams, $params); if (isset($params['logs_action_id'])) { $this->logsActionId = (int) $params['logs_action_id']; unset($params['logs_action_id']); } else { $this->logsActionId = Mage::getModel('M2ePro/Listing_Other_Log')->getNextActionId(); } $this->otherListing = $otherListing; parent::__construct($params, $this->otherListing->getMarketplace(), $this->otherListing->getAccount(), NULL); }
/** * @return Ess_M2ePro_Model_Ebay_Listing_Other_Action_Locker */ protected function getLocker() { if (is_null($this->locker)) { $this->locker = Mage::getModel('M2ePro/Ebay_Listing_Other_Action_Locker'); $this->locker->setListingOtherId($this->otherListing->getId()); } return $this->locker; }
/** * @return Ess_M2ePro_Model_Ebay_Listing_Other_Action_Type_Response */ protected function getResponseObject() { if (is_null($this->responseObject)) { /** @var Ess_M2ePro_Model_Ebay_Listing_Other_Action_Type_Response $response */ $response = Mage::getModel('M2ePro/Ebay_Listing_Other_Action_Type_' . $this->getOrmActionType() . '_Response'); $response->setParams($this->params); $response->setListingOther($this->otherListing); $response->setConfigurator($this->otherListing->getActionConfigurator()); $response->setRequestData($this->getRequestDataObject()); $this->responseObject = $response; } return $this->responseObject; }
protected function setMarketplaceByOtherListingProduct(Ess_M2ePro_Model_Listing_Other $otherListing) { if (!is_null($this->marketplace) && $this->marketplace->getId() == $otherListing->getMarketplaceId()) { return; } $this->marketplace = Mage::helper('M2ePro/Component_Amazon')->getObject('Marketplace', $otherListing->getMarketplaceId()); }
protected function setAccountByOtherListingProduct(Ess_M2ePro_Model_Listing_Other $otherListing) { if (!is_null($this->account) && $this->account->getId() == $otherListing->getAccountId()) { return; } $this->account = Mage::helper('M2ePro/Component_Buy')->getCachedObject('Account', $otherListing->getAccountId()); $this->mappingSettings = NULL; }
public function addProductFromOther(Ess_M2ePro_Model_Listing_Other $listingOtherProduct, $checkingMode = false, $checkHasProduct = true) { if (!$listingOtherProduct->getProductId()) { return false; } $productId = $listingOtherProduct->getProductId(); $result = $this->getParentObject()->addProduct($productId, $checkingMode, $checkHasProduct); if ($checkingMode) { return $result; } if (!$result instanceof Ess_M2ePro_Model_Listing_Product) { return false; } $listingProduct = $result; $listingProduct->getChildObject()->getBuyItem()->setData('store_id', $this->getParentObject()->getStoreId())->save(); $dataForUpdate = array('general_id' => $listingOtherProduct->getChildObject()->getGeneralId(), 'sku' => $listingOtherProduct->getChildObject()->getSku(), 'online_price' => $listingOtherProduct->getChildObject()->getOnlinePrice(), 'online_qty' => $listingOtherProduct->getChildObject()->getOnlineQty(), 'condition' => $listingOtherProduct->getChildObject()->getCondition(), 'condition_note' => $listingOtherProduct->getChildObject()->getConditionNote(), 'shipping_standard_rate' => $listingOtherProduct->getChildObject()->getShippingStandardRate(), 'shipping_expedited_mode' => $listingOtherProduct->getChildObject()->getShippingExpeditedMode(), 'shipping_expedited_rate' => $listingOtherProduct->getChildObject()->getShippingExpeditedRate(), 'status' => $listingOtherProduct->getStatus(), 'status_changer' => $listingOtherProduct->getStatusChanger()); $listingProduct->addData($dataForUpdate)->save(); return $listingProduct; }
private function isMeetRelistRequirements(Ess_M2ePro_Model_Listing_Other $listingOther) { // eBay available status //-------------------- if ($listingOther->isListed()) { return false; } if (!$listingOther->isRelistable()) { return false; } if (is_null($listingOther->getProductId())) { return false; } if ($this->_runnerActions->isExistProductAction($listingOther, Ess_M2ePro_Model_Connector_Ebay_Item_Dispatcher::ACTION_RELIST, array())) { return false; } //-------------------- // Correct synchronization //-------------------- if (!$listingOther->getAccount()->getChildObject()->isOtherListingsMappedSynchronizationEnabled()) { return false; } if (!$listingOther->getChildObject()->getSynchronizationModel()->isRelistMode()) { return false; } if ($listingOther->getChildObject()->getSynchronizationModel()->isRelistFilterUserLock() && $listingOther->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) { return false; } //-------------------- // Check filters //-------------------- if ($listingOther->getChildObject()->getSynchronizationModel()->isRelistStatusEnabled()) { if ($listingOther->getMagentoProduct()->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED) { return false; } } if ($listingOther->getChildObject()->getSynchronizationModel()->isRelistIsInStock()) { if (!$listingOther->getMagentoProduct()->getStockAvailability()) { return false; } } if ($listingOther->getChildObject()->getSynchronizationModel()->isRelistWhenQtyHasValue()) { $productQty = $listingOther->getChildObject()->getMappedQty(); if (!is_null($productQty)) { $result = false; /** @var $ebaySynchronizationTemplate Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization */ $ebaySynchronizationTemplate = $listingOther->getChildObject()->getSynchronizationModel(); $typeQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyHasValueType(); $minQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyHasValueMin(); $maxQty = (int) $ebaySynchronizationTemplate->getRelistWhenQtyHasValueMax(); if ($typeQty == Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization::RELIST_QTY_LESS && $productQty <= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization::RELIST_QTY_MORE && $productQty >= $minQty) { $result = true; } if ($typeQty == Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization::RELIST_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) { $result = true; } if (!$result) { return false; } } } //-------------------- return true; }
/** * @param Ess_M2ePro_Model_Listing_Other $listingOtherProduct * @param bool $checkingMode * @param bool $checkHasProduct * @return bool|Ess_M2ePro_Model_Listing_Product * @throws Ess_M2ePro_Model_Exception_Logic */ public function addProductFromOther(Ess_M2ePro_Model_Listing_Other $listingOtherProduct, $checkingMode = false, $checkHasProduct = true) { if (!$listingOtherProduct->getProductId()) { return false; } $productId = $listingOtherProduct->getProductId(); $result = $this->getParentObject()->addProduct($productId, $checkingMode, $checkHasProduct); if ($checkingMode) { return $result; } if (!$result instanceof Ess_M2ePro_Model_Listing_Product) { return false; } $listingProduct = $result; /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */ $amazonListingProduct = $listingProduct->getChildObject(); $variationManager = $amazonListingProduct->getVariationManager(); if ($variationManager->isRelationParentType()) { $variationManager->switchModeToAnother(); } $amazonListingProduct->getAmazonItem()->setData('store_id', $this->getParentObject()->getStoreId())->save(); /** @var Ess_M2ePro_Model_Amazon_Listing_Other $amazonListingOther */ $amazonListingOther = $listingOtherProduct->getChildObject(); $dataForUpdate = array('general_id' => $amazonListingOther->getGeneralId(), 'sku' => $amazonListingOther->getSku(), 'online_price' => $amazonListingOther->getOnlinePrice(), 'online_qty' => $amazonListingOther->getOnlineQty(), 'is_afn_channel' => (int) $amazonListingOther->isAfnChannel(), 'is_isbn_general_id' => (int) $amazonListingOther->isIsbnGeneralId(), 'status' => $listingOtherProduct->getStatus(), 'status_changer' => $listingOtherProduct->getStatusChanger()); $listingProduct->addData($dataForUpdate)->save(); return $listingProduct; }
public function addProductFromOther(Ess_M2ePro_Model_Listing_Other $listingOtherProduct) { if (!$listingOtherProduct->getProductId()) { return false; } $productId = $listingOtherProduct->getProductId(); $listingProduct = $this->getParentObject()->addProduct($productId); if (!$listingProduct instanceof Ess_M2ePro_Model_Listing_Product) { return false; } $listingProduct->getChildObject()->getAmazonItem()->setData('store_id', $this->getParentObject()->getStoreId())->save(); $dataForUpdate = array('general_id' => $listingOtherProduct->getChildObject()->getGeneralId(), 'sku' => $listingOtherProduct->getChildObject()->getSku(), 'online_price' => $listingOtherProduct->getChildObject()->getOnlinePrice(), 'online_qty' => $listingOtherProduct->getChildObject()->getOnlineQty(), 'is_afn_channel' => (int) $listingOtherProduct->getChildObject()->isAfnChannel(), 'is_isbn_general_id' => (int) $listingOtherProduct->getChildObject()->isIsbnGeneralId(), 'start_date' => $listingOtherProduct->getChildObject()->getStartDate(), 'end_date' => $listingOtherProduct->getChildObject()->getEndDate(), 'status' => $listingOtherProduct->getStatus(), 'status_changer' => $listingOtherProduct->getStatusChanger()); $listingProduct->addData($dataForUpdate)->save(); return $listingProduct; }
public function addProductFromOther(Ess_M2ePro_Model_Listing_Other $listingOtherProduct) { if (!$listingOtherProduct->getProductId()) { return false; } $productId = $listingOtherProduct->getProductId(); $listingProduct = $this->getParentObject()->addProduct($productId); if (!$listingProduct instanceof Ess_M2ePro_Model_Listing_Product) { return false; } $ebayItem = Mage::getModel('M2ePro/Ebay_Item')->loadInstance($listingOtherProduct->getChildObject()->getItemId(), 'item_id'); $ebayItem->setData('store_id', $this->getParentObject()->getStoreId())->save(); $dataForUpdate = array('ebay_item_id' => $ebayItem->getId(), 'online_sku' => $listingOtherProduct->getChildObject()->getSku(), 'online_title' => $listingOtherProduct->getChildObject()->getTitle(), 'online_buyitnow_price' => $listingOtherProduct->getChildObject()->getOnlinePrice(), 'online_qty' => $listingOtherProduct->getChildObject()->getOnlineQty(), 'online_qty_sold' => $listingOtherProduct->getChildObject()->getOnlineQtySold(), 'online_bids' => $listingOtherProduct->getChildObject()->getOnlineBids(), 'online_start_date' => $listingOtherProduct->getChildObject()->getStartDate(), 'online_end_date' => $listingOtherProduct->getChildObject()->getEndDate(), 'status' => $listingOtherProduct->getStatus(), 'status_changer' => $listingOtherProduct->getStatusChanger(), 'is_m2epro_listed_item' => 0); $listingProduct->addData($dataForUpdate)->save(); return $listingProduct; }
private function inspectRevisePriceRequirements(Ess_M2ePro_Model_Listing_Other $listingOther) { // Prepare actions params //-------------------- $actionParams = array('only_data' => array('price' => true)); //-------------------- // eBay available status //-------------------- if (!$listingOther->isListed()) { return false; } if (!$listingOther->isRevisable()) { return false; } if (is_null($listingOther->getProductId())) { return false; } if ($this->getRunner()->isExistProduct($listingOther, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams)) { return false; } //-------------------- /* @var $ebaySynchronizationTemplate Ess_M2ePro_Model_Ebay_Listing_Other_Synchronization */ $ebaySynchronizationTemplate = $listingOther->getChildObject()->getSynchronizationModel(); // Correct synchronization //-------------------- if (!$ebaySynchronizationTemplate->isMode()) { return false; } if (!$ebaySynchronizationTemplate->isReviseWhenChangePrice()) { return false; } //-------------------- // Check filters //-------------------- $ebayListingOther = $listingOther->getChildObject(); $currentPrice = $ebayListingOther->getMappedPrice(); if (is_null($currentPrice)) { return false; } $onlinePrice = $ebayListingOther->getOnlinePrice(); if ($currentPrice != $onlinePrice) { $this->getRunner()->addProduct($listingOther, Ess_M2ePro_Model_Listing_Product::ACTION_REVISE, $actionParams); return true; } //-------------------- return false; }
protected function eventAfterProcess() { $lockItem = Mage::getModel('M2ePro/LockItem'); $lockItem->setNick(Ess_M2ePro_Helper_Component_Ebay::NICK . '_listing_other_' . $this->otherListing->getId()); $lockItem->remove(); }
private function logOtherListingMessage(Ess_M2ePro_Model_Listing_Other $otherListing, $action, $oldValue, $newValue, $messagePostfix = '') { // M2ePro_TRANSLATIONS // From [%from%] to [%to%]. $log = Mage::getModel('M2ePro/Listing_Other_Log'); $log->setComponentMode($otherListing->getComponentMode()); $oldValue = strlen($oldValue) > 150 ? substr($oldValue, 0, 150) . ' ...' : $oldValue; $newValue = strlen($newValue) > 150 ? substr($newValue, 0, 150) . ' ...' : $newValue; $messagePostfix = trim(trim($messagePostfix), '.'); if (!empty($messagePostfix)) { $messagePostfix = ' ' . $messagePostfix; } $log->addProductMessage($otherListing->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); }
private function modifyAndLogListingOther(Ess_M2ePro_Model_Listing_Other $listingOther, $status, $duplicateItemId = null) { /** @var Ess_M2ePro_Model_Listing_Other_Log $logModel */ $logModel = Mage::getModel('M2ePro/Listing_Other_Log'); $logModel->setComponentMode(Ess_M2ePro_Helper_Component_Ebay::NICK); $logActionId = $logModel->getNextActionId(); $statusLogMessage = $this->getStatusLogMessage($listingOther->getStatus(), $status); $logModel->addProductMessage($listingOther->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, $logActionId, Ess_M2ePro_Model_Listing_Other_Log::ACTION_CHANNEL_CHANGE, $statusLogMessage, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); $additionalData = $listingOther->getAdditionalData(); unset($additionalData['last_failed_action_data']); $listingOther->addData(array('status' => $status, 'additional_data' => json_encode($additionalData)))->save(); 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 = Mage::helper('M2ePro')->__($textToTranslate, $duplicateItemId); $logModel->addProductMessage($listingOther->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, $logActionId, Ess_M2ePro_Model_Listing_Other_Log::ACTION_CHANNEL_CHANGE, $duplicateDeletedMessage, Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); }
private function logOtherListingMessage(Ess_M2ePro_Model_Listing_Other $otherListing, $action, $oldValue, $newValue) { // M2ePro_TRANSLATIONS // From [%from%] to [%to%]. $log = Mage::getModel('M2ePro/Listing_Other_Log'); $log->setComponentMode($otherListing->getComponentMode()); $log->addProductMessage($otherListing->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]', array('from' => $oldValue, 'to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); }
/** * @param Ess_M2ePro_Model_Listing_Other $listingOther * @return bool * @throws Ess_M2ePro_Model_Exception_Logic */ protected function isMeetReviseGeneralRequirements(Ess_M2ePro_Model_Listing_Other $listingOther) { if (!$listingOther->isListed() || !$listingOther->isRevisable()) { return false; } if (is_null($listingOther->getProductId())) { return false; } /** @var Ess_M2ePro_Model_Ebay_Listing_Other $ebayListingOther */ $ebayListingOther = $listingOther->getChildObject(); $ebaySynchronizationTemplate = $ebayListingOther->getSynchronizationModel(); if (!$ebaySynchronizationTemplate->isMode()) { return false; } return true; }
public function addProductFromOther(Ess_M2ePro_Model_Listing_Other $listingOtherProduct, $checkingMode = false, $checkHasProduct = true) { if (!$listingOtherProduct->getProductId()) { return false; } $productId = $listingOtherProduct->getProductId(); $result = $this->getParentObject()->addProduct($productId, $checkingMode, $checkHasProduct); if ($checkingMode) { return $result; } if (!$result instanceof Ess_M2ePro_Model_Listing_Product) { return false; } $listingProduct = $result; $listingProduct->getChildObject()->getPlayItem()->setData('store_id', $this->getParentObject()->getStoreId())->save(); $dataForUpdate = array('general_id' => $listingOtherProduct->getChildObject()->getGeneralId(), 'play_listing_id' => $listingOtherProduct->getChildObject()->getPlayListingId(), 'link_info' => $listingOtherProduct->getChildObject()->getLinkInfo(), 'general_id_type' => $listingOtherProduct->getChildObject()->getGeneralIdType(), 'sku' => $listingOtherProduct->getChildObject()->getSku(), 'online_price_gbr' => $listingOtherProduct->getChildObject()->getOnlinePriceGbr(), 'online_price_euro' => $listingOtherProduct->getChildObject()->getOnlinePriceEuro(), 'online_shipping_price_gbr' => 0, 'online_shipping_price_euro' => 0, 'online_qty' => $listingOtherProduct->getChildObject()->getOnlineQty(), 'condition' => $listingOtherProduct->getChildObject()->getCondition(), 'condition_note' => $listingOtherProduct->getChildObject()->getConditionNote(), 'dispatch_to' => $listingOtherProduct->getChildObject()->getDispatchTo(), 'dispatch_from' => $listingOtherProduct->getChildObject()->getDispatchFrom(), 'status' => $listingOtherProduct->getStatus(), 'status_changer' => $listingOtherProduct->getStatusChanger()); $listingProduct->addData($dataForUpdate)->save(); return $listingProduct; }
protected function updateProductAfterAction(Ess_M2ePro_Model_Listing_Other $listingOther, array $nativeRequestData = array(), array $params = array(), $ebayItemId = NULL, $saveEbayQtySold = false) { $dataForUpdate = array('status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED); !is_null($ebayItemId) && ($dataForUpdate['item_id'] = $ebayItemId); 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 (isset($nativeRequestData['title'])) { $dataForUpdate['title'] = $nativeRequestData['title']; } if ($saveEbayQtySold) { $dataForUpdate['online_qty_sold'] = is_null($listingOther->getChildObject()->getOnlineQtySold()) ? 0 : $listingOther->getChildObject()->getOnlineQtySold(); if (isset($nativeRequestData['qty'])) { $dataForUpdate['online_qty'] = (int) $nativeRequestData['qty'] + (int) $dataForUpdate['online_qty_sold']; } } else { $dataForUpdate['online_qty_sold'] = 0; if (isset($nativeRequestData['qty'])) { $dataForUpdate['online_qty'] = (int) $nativeRequestData['qty']; } } if (isset($nativeRequestData['price_fixed'])) { $dataForUpdate['online_price'] = (double) $nativeRequestData['price_fixed']; } $listingOther->addData($dataForUpdate)->save(); }
public function addProductFromOther(Ess_M2ePro_Model_Listing_Other $listingOtherProduct, $checkingMode = false, $checkHasProduct = true) { if (!$listingOtherProduct->getProductId()) { return false; } $productId = $listingOtherProduct->getProductId(); $result = $this->getParentObject()->addProduct($productId, $checkingMode, true); if ($checkingMode) { return $result; } if (!$result instanceof Ess_M2ePro_Model_Listing_Product) { return false; } $listingProduct = $result; /** @var $collection Mage_Core_Model_Mysql4_Collection_Abstract */ $collection = Mage::getModel('M2ePro/Ebay_Item')->getCollection()->addFieldToFilter('account_id', $listingOtherProduct->getAccount()->getId())->addFieldToFilter('item_id', $listingOtherProduct->getChildObject()->getItemId()); $ebayItem = $collection->getFirstItem(); $ebayItem->setData('store_id', $this->getParentObject()->getStoreId())->save(); $dataForUpdate = array('ebay_item_id' => $ebayItem->getId(), 'online_sku' => $listingOtherProduct->getChildObject()->getSku(), 'online_title' => $listingOtherProduct->getChildObject()->getTitle(), 'online_buyitnow_price' => $listingOtherProduct->getChildObject()->getOnlinePrice(), 'online_qty' => $listingOtherProduct->getChildObject()->getOnlineQty(), 'online_qty_sold' => $listingOtherProduct->getChildObject()->getOnlineQtySold(), 'online_bids' => $listingOtherProduct->getChildObject()->getOnlineBids(), 'start_date' => $listingOtherProduct->getChildObject()->getStartDate(), 'end_date' => $listingOtherProduct->getChildObject()->getEndDate(), 'status' => $listingOtherProduct->getStatus(), 'status_changer' => $listingOtherProduct->getStatusChanger()); $listingProduct->addData($dataForUpdate)->save(); return $listingProduct; }
private function inspectRevisePriceRequirements(Ess_M2ePro_Model_Listing_Other $listingOther) { // Prepare actions params //-------------------- $actionParams = array('only_data' => array('price' => true)); //-------------------- // eBay available status //-------------------- if (!$listingOther->isListed()) { return false; } if (!$listingOther->isRevisable()) { return false; } if (is_null($listingOther->getProductId())) { return false; } if ($this->_runnerActions->isExistProductAction($listingOther, Ess_M2ePro_Model_Connector_Server_Ebay_Item_Dispatcher::ACTION_REVISE, $actionParams)) { return false; } //-------------------- // Correct synchronization //-------------------- if (!$listingOther->getAccount()->getChildObject()->isOtherListingsMappedSynchronizationEnabled()) { return false; } if (!$listingOther->getChildObject()->getSynchronizationModel()->isReviseWhenChangePrice()) { return false; } //-------------------- // Check filters //-------------------- $ebayListingOther = $listingOther->getChildObject(); $currentPrice = $ebayListingOther->getMappedPrice(); if (is_null($currentPrice)) { return false; } $onlinePrice = $ebayListingOther->getOnlinePrice(); if ($currentPrice != $onlinePrice) { $this->_runnerActions->setProduct($listingOther, Ess_M2ePro_Model_Connector_Server_Ebay_Item_Dispatcher::ACTION_REVISE, $actionParams); return true; } //-------------------- return false; }