diff --git a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product.php b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product.php index 406dafc2e..7b7bc3c1b 100644 --- a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product.php +++ b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product.php @@ -6,6 +6,8 @@ * @license Commercial use is forbidden */ +use Ess_M2ePro_Model_Resource_Amazon_Listing_Product as Resource; + /** * @method Ess_M2ePro_Model_Listing_Product getParentObject() */ @@ -1217,4 +1219,14 @@ public function mapChannelItemProduct() } //######################################## + + /** + * @return bool + */ + public function isStoppedManually() + { + return (bool)$this->getData(Resource::IS_STOPPED_MANUALLY_FIELD); + } + + //######################################## } diff --git a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Delete/Response.php b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Delete/Response.php index 023abee18..214dc6a4c 100644 --- a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Delete/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Delete/Response.php @@ -25,6 +25,7 @@ public function processSuccess($params = array()) ); $data = $this->appendStatusChangerValue($data); + $data = $this->appendIsStoppedManually($data, false); $this->getListingProduct()->addData($data); $this->getListingProduct()->save(); diff --git a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/List/Response.php b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/List/Response.php index b54c70c01..454be9cd5 100644 --- a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/List/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/List/Response.php @@ -27,6 +27,7 @@ public function processSuccess($params = array()) $data = $this->appendIdentifiersData($data, $generalId); $data = $this->appendDetailsValues($data); $data = $this->appendImagesValues($data); + $data = $this->appendIsStoppedManually($data, false); $variationManager = $this->getAmazonListingProduct()->getVariationManager(); diff --git a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Relist/Response.php b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Relist/Response.php index ba56e98b2..668c90af4 100644 --- a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Relist/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Relist/Response.php @@ -34,6 +34,7 @@ public function processSuccess($params = array()) $data = $this->appendBusinessPriceValues($data); $data = $this->processRecheckInstructions($data); + $data = $this->appendIsStoppedManually($data, false); if (isset($data['additional_data'])) { $data['additional_data'] = Mage::helper('M2ePro')->jsonEncode($data['additional_data']); diff --git a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Response.php b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Response.php index a3be13c27..01e4a2cef 100644 --- a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Response.php @@ -306,6 +306,17 @@ protected function appendImagesValues($data) return $data; } + /** + * @param array $data + * @param bool $value + * @return array + */ + protected function appendIsStoppedManually($data, $value) + { + $data[Ess_M2ePro_Model_Resource_Amazon_Listing_Product::IS_STOPPED_MANUALLY_FIELD] = $value; + return $data; + } + //######################################## protected function appendGiftSettingsStatus($data) diff --git a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Revise/Response.php b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Revise/Response.php index ef85f141a..53171a154 100644 --- a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Revise/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Revise/Response.php @@ -33,6 +33,7 @@ public function processSuccess($params = array()) $data = $this->appendGiftSettingsStatus($data); $data = $this->appendDetailsValues($data); $data = $this->appendImagesValues($data); + $data = $this->appendIsStoppedManually($data, false); if (isset($data['additional_data'])) { $data['additional_data'] = Mage::helper('M2ePro')->jsonEncode($data['additional_data']); diff --git a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Stop/Response.php b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Stop/Response.php index c84b1d7a7..a723bf69a 100644 --- a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Stop/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Action/Type/Stop/Response.php @@ -23,6 +23,10 @@ public function processSuccess($params = array()) $data = $this->appendStatusChangerValue($data); $data = $this->appendQtyValues($data); + $isStoppedManually = $this->getListingProduct()->isStopped() && $this->getListingProduct()->getStatusChanger() + === Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER; + $data = $this->appendIsStoppedManually($data, $isStoppedManually); + $this->getListingProduct()->addData($data); $this->setLastSynchronizationDates(); diff --git a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Instruction/SynchronizationTemplate/Checker/Inactive.php b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Instruction/SynchronizationTemplate/Checker/Inactive.php index 67864a52d..108bc4c67 100644 --- a/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Instruction/SynchronizationTemplate/Checker/Inactive.php +++ b/app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Instruction/SynchronizationTemplate/Checker/Inactive.php @@ -149,8 +149,10 @@ public function isMeetRelistRequirements() return false; } - if ($amazonSynchronizationTemplate->isRelistFilterUserLock() && - $listingProduct->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) { + if ( + $amazonSynchronizationTemplate->isRelistFilterUserLock() + && $amazonListingProduct->isStoppedManually() + ) { return false; } diff --git a/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Creator.php b/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Creator.php index ba7edde17..e94b9db19 100644 --- a/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Creator.php +++ b/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Creator.php @@ -37,11 +37,16 @@ public function processEbayOrders(Ess_M2ePro_Model_Account $account, array $orde { $orders = array(); $accountCreateDate = new DateTime($account->getData('create_date'), new DateTimeZone('UTC')); + $boundaryCreationDate = (new DateTime('now', new DateTimeZone('UTC'))); + $boundaryCreationDate = $boundaryCreationDate->modify('-90 days'); foreach ($ordersData as $ebayOrderData) { try { $orderCreateDate = new DateTime($ebayOrderData['purchase_create_date'], new DateTimeZone('UTC')); - if ($this->_validateAccountCreateDate && $orderCreateDate < $accountCreateDate) { + if ( + $this->_validateAccountCreateDate + && ($orderCreateDate < $accountCreateDate || $orderCreateDate < $boundaryCreationDate) + ) { continue; } diff --git a/app/code/community/Ess/M2ePro/Model/Cron/Task/Repository.php b/app/code/community/Ess/M2ePro/Model/Cron/Task/Repository.php index 6c0f16700..50e17c9fb 100644 --- a/app/code/community/Ess/M2ePro/Model/Cron/Task/Repository.php +++ b/app/code/community/Ess/M2ePro/Model/Cron/Task/Repository.php @@ -293,10 +293,6 @@ class Ess_M2ePro_Model_Cron_Task_Repository 'component' => Ess_M2ePro_Helper_Component_Walmart::NICK, 'group' => self::GROUP_WALMART, ), - Ess_M2ePro_Model_Cron_Task_Walmart_Order_ReceiveWithCancellationRequested::NICK => array( - 'component' => Ess_M2ePro_Helper_Component_Walmart::NICK, - 'group' => self::GROUP_WALMART, - ), Ess_M2ePro_Model_Cron_Task_Walmart_Order_CreateFailed::NICK => array( 'component' => Ess_M2ePro_Helper_Component_Walmart::NICK, 'group' => self::GROUP_WALMART, diff --git a/app/code/community/Ess/M2ePro/Model/Cron/Task/Walmart/Order/Receive.php b/app/code/community/Ess/M2ePro/Model/Cron/Task/Walmart/Order/Receive.php index 6b2f08d95..78c6033d9 100644 --- a/app/code/community/Ess/M2ePro/Model/Cron/Task/Walmart/Order/Receive.php +++ b/app/code/community/Ess/M2ePro/Model/Cron/Task/Walmart/Order/Receive.php @@ -60,7 +60,7 @@ protected function performActions() $processedWalmartOrders = $ordersCreator->processWalmartOrders($account, $responseData['items']); $ordersCreator->processMagentoOrders($processedWalmartOrders); - $account->getChildObject()->setData('orders_last_synchronization', $responseData['to_create_date']); + $account->getChildObject()->setData('orders_last_synchronization', $responseData['to_update_date']); $account->getChildObject()->save(); } catch (Exception $exception) { $message = Mage::helper('M2ePro')->__( @@ -84,7 +84,7 @@ protected function performActions() protected function receiveWalmartOrdersData(Ess_M2ePro_Model_Account $account) { $fromDate = $this->prepareFromDate($account->getData('orders_last_synchronization')); - $toDate = $this->prepareToDate(); + $toDate = new DateTime('now', new DateTimeZone('UTC')); // ---------------------------------------- @@ -97,64 +97,53 @@ protected function receiveWalmartOrdersData(Ess_M2ePro_Model_Account $account) /** @var Ess_M2ePro_Model_Walmart_Connector_Dispatcher $dispatcherObject */ $dispatcherObject = Mage::getModel('M2ePro/Walmart_Connector_Dispatcher'); - $orders = array(array()); - $breakDate = null; // ------------------------------------- - do { - $connectorObj = $dispatcherObject->getVirtualConnector( - 'orders', 'get', 'items', - array( - 'account' => $account->getData('server_hash'), - 'from_create_date' => $fromDate->format('Y-m-d H:i:s'), - 'to_create_date' => $toDate->format('Y-m-d H:i:s') - ) - ); - $dispatcherObject->process($connectorObj); - - // ---------------------------------------- - - $this->processResponseMessages($connectorObj->getResponseMessages()); - - // ---------------------------------------- - - $responseData = $connectorObj->getResponseData(); - if (!isset($responseData['items']) || !isset($responseData['to_create_date'])) { - Mage::helper('M2ePro/Module_Logger')->process( - array( - 'from_create_date' => $fromDate->format('Y-m-d H:i:s'), - 'to_create_date' => $toDate->format('Y-m-d H:i:s'), - 'account_id' => $account->getId(), - 'response_data' => $responseData, - 'response_messages' => $connectorObj->getResponseMessages() - ), - 'Walmart orders receive task - empty response' - ); + $connectorObj = $dispatcherObject->getVirtualConnector( + 'orders', + 'get', + 'items', + array( + 'account' => $account->getData('server_hash'), + 'from_update_date' => $fromDate->format('Y-m-d H:i:s'), + 'to_update_date' => $toDate->format('Y-m-d H:i:s') + ) + ); + $dispatcherObject->process($connectorObj); - return array(); - } + // ---------------------------------------- - // ---------------------------------------- + $this->processResponseMessages($connectorObj->getResponseMessages()); - $fromDate = new DateTime($responseData['to_create_date'], new DateTimeZone('UTC')); - if ($breakDate !== null && $breakDate->getTimestamp() === $fromDate->getTimestamp()) { - break; - } + // ---------------------------------------- - $orders[] = $responseData['items']; - $breakDate = $fromDate; + $responseData = $connectorObj->getResponseData(); + if (!isset($responseData['items'])) { + Mage::helper('M2ePro/Module_Logger')->process( + array( + 'from_update_date' => $fromDate->format('Y-m-d H:i:s'), + 'to_update_date' => $toDate->format('Y-m-d H:i:s'), + 'account_id' => $account->getId(), + 'response_data' => $responseData, + 'response_messages' => $connectorObj->getResponseMessages() + ), + 'Walmart orders receive task - empty response' + ); - if ($fromDate > $toDate) { - break; - } - } while (!empty($responseData['items'])); + return array(); + } // ---------------------------------------- return array( - 'items' => call_user_func_array('array_merge', $orders), - 'to_create_date' => $responseData['to_create_date'] + 'items' => $responseData['items'], + 'to_create_date' => isset($responseData['to_create_date']) + ? $responseData['to_create_date'] + : $toDate->format('Y-m-d H:i:s'), + 'to_update_date' => count($responseData['items']) > 0 + ? $responseData['to_update_date'] + : $toDate->format('Y-m-d H:i:s'), ); } @@ -179,45 +168,6 @@ protected function processResponseMessages(array $messages = array()) } } - //######################################## - - /** - * @param DateTime $minPurchaseDateTime - * @return DateTime|null - * @throws Exception - */ - protected function getMinPurchaseDateTime(DateTime $minPurchaseDateTime) - { - /** @var Ess_M2ePro_Model_Resource_Order_Collection $collection */ - $collection = Mage::helper('M2ePro/Component_Walmart')->getCollection('Order'); - $collection->addFieldToFilter( - 'status', - array( - 'from' => Ess_M2ePro_Model_Walmart_Order::STATUS_CREATED, - 'to' => Ess_M2ePro_Model_Walmart_Order::STATUS_SHIPPED_PARTIALLY - ) - ); - $collection->addFieldToFilter( - 'purchase_create_date', - array('from' => $minPurchaseDateTime->format('Y-m-d H:i:s')) - ); - $collection->getSelect()->limit(1); - - /** @var Ess_M2ePro_Model_Order $order */ - $order = $collection->getFirstItem(); - if ($order->getId() === null) { - return null; - } - - $purchaseDateTime = new DateTime( - $order->getChildObject()->getPurchaseCreateDate(), - new DateTimeZone('UTC') - ); - $purchaseDateTime->modify('-1 second'); - - return $purchaseDateTime; - } - //#################################### /** @@ -233,49 +183,13 @@ protected function prepareFromDate($lastFromDate) if (!empty($lastFromDate)) { $lastFromDate = new DateTime($lastFromDate, new DateTimeZone('UTC')); - } - - if (empty($lastFromDate)) { + } else { $lastFromDate = clone $nowDateTime; + $lastFromDate = $lastFromDate->modify('-1 day'); } - // ---------------------------------------- - - $minDateTime = clone $nowDateTime; - $minDateTime->modify('-1 day'); - - if ($lastFromDate > $minDateTime) { - $minPurchaseDateTime = $this->getMinPurchaseDateTime($minDateTime); - if ($minPurchaseDateTime !== null) { - $lastFromDate = $minPurchaseDateTime; - } - } - - // ---------------------------------------- - - $minDateTime = clone $nowDateTime; - $minDateTime->modify('-30 days'); - - if ((int)$lastFromDate->format('U') < (int)$minDateTime->format('U')) { - $lastFromDate = $minDateTime; - } - - // --------------------------------------- - return $lastFromDate; } - /** - * @return DateTime - * @throws Exception - */ - protected function prepareToDate() - { - $operationHistory = $this->getOperationHistory()->getParentObject('cron_runner'); - $toDate = $operationHistory !== null ? $operationHistory->getData('start_date') : 'now'; - - return new DateTime($toDate, new DateTimeZone('UTC')); - } - //######################################## } diff --git a/app/code/community/Ess/M2ePro/Model/Cron/Task/Walmart/Order/ReceiveWithCancellationRequested.php b/app/code/community/Ess/M2ePro/Model/Cron/Task/Walmart/Order/ReceiveWithCancellationRequested.php deleted file mode 100644 index 3afeade78..000000000 --- a/app/code/community/Ess/M2ePro/Model/Cron/Task/Walmart/Order/ReceiveWithCancellationRequested.php +++ /dev/null @@ -1,274 +0,0 @@ -_dataHelper = Mage::helper('M2ePro'); - $this->_serverMaintenanceHelper = Mage::helper('M2ePro/Server_Maintenance'); - $this->_moduleLoggerHelper = Mage::helper('M2ePro/Module_Logger'); - $this->_registryManager = Mage::getModel('M2ePro/Registry_Manager'); - } - - /** - * @return Ess_M2ePro_Model_Synchronization_Log - */ - protected function getSynchronizationLog() - { - if ($this->_synchronizationLog === null) { - $this->_synchronizationLog = parent::getSynchronizationLog(); - - $this->_synchronizationLog->setComponentMode(Ess_M2ePro_Helper_Component_Walmart::NICK); - $this->_synchronizationLog->setSynchronizationTask(Ess_M2ePro_Model_Synchronization_Log::TASK_ORDERS); - } - - return $this->_synchronizationLog; - } - - public function isPossibleToRun() - { - if ($this->_serverMaintenanceHelper->isNow()) { - return false; - } - - return parent::isPossibleToRun(); - } - - protected function performActions() - { - /** @var $accountsCollection Mage_Core_Model_Resource_Db_Collection_Abstract */ - $accountsCollection = Mage::helper('M2ePro/Component_Walmart')->getCollection('Account'); - - /** @var $account Ess_M2ePro_Model_Account **/ - foreach ($accountsCollection->getItems() as $account) { - try { - $accountId = (int)$account->getId(); - if (!$this->isItemsReceiveRequired($accountId)) { - continue; - } - - $this->_accountSynchronizationFail = false; - $responseData = $this->receiveOrderItems($account, $this->getReceiveInterval($accountId)); - $this->processOrderItems($responseData); - - if (!$this->_accountSynchronizationFail) { - $this->updateLastReceiveDate($accountId); - } - } catch (Exception $exception) { - $message = $this->_dataHelper->__( - 'The "Receive Orders with Buyer Cancellation Requested" ' - . 'Action for Walmart Account "%title%" was completed with error.', - $account->getTitle() - ); - - $this->processTaskAccountException($message, __FILE__, __LINE__); - $this->processTaskException($exception); - } - } - } - - /** - * @param int $accountId - * - * @return string - */ - protected function getRegistryKey($accountId) - { - return self::REGISTRY_PREFIX . $accountId . self::REGISTRY_SUFFIX; - } - - /** - * @param int $accountId - * @return bool - */ - protected function isItemsReceiveRequired($accountId) - { - $lastUpdate = $this->_registryManager->getValue($this->getRegistryKey($accountId)); - if (!$lastUpdate) { - return true; - } - - $now = $this->_dataHelper->createCurrentGmtDateTime(); - $lastUpdateDateTime = $this->_dataHelper->createGmtDateTime($lastUpdate); - return $now->getTimestamp() - $lastUpdateDateTime->getTimestamp() > self::INTERVAL_FOR_ACCOUNT_SYNCHRONIZATION; - } - - /** - * @param int $accountId - * @return void - */ - protected function updateLastReceiveDate($accountId) - { - $now = $this->_dataHelper->createCurrentGmtDateTime(); - $this->_registryManager->setValue( - $this->getRegistryKey($accountId), - $now->format('Y-m-d H:i:s') - ); - } - - /** - * @param int $accountId - * - * @return int - */ - protected function getReceiveInterval($accountId) - { - $lastUpdate = $this->_registryManager->getValue($this->getRegistryKey($accountId)); - - return $lastUpdate ? - self::INTERVAL_TO_COMMON_CHECK_BUYER_CANCELLATION_REQUESTS - : self::INTERVAL_TO_FIRST_CHECK_BUYER_CANCELLATION_REQUESTS; - } - - /** - * @param Ess_M2ePro_Model_Account $account - * @param int $interval - * @return array|mixed - * @throws Exception - */ - protected function receiveOrderItems(Ess_M2ePro_Model_Account $account, $interval) - { - $fromDate = $this->_dataHelper->createCurrentGmtDateTime(); - $fromDate->modify("-$interval seconds"); - - /** @var Ess_M2ePro_Model_Walmart_Connector_Dispatcher $dispatcherObject */ - $dispatcherObject = Mage::getModel('M2ePro/Walmart_Connector_Dispatcher'); - $connectorObj = $dispatcherObject->getConnector( - 'orders', - 'get', - 'itemsCancellationRequested', - array( - 'account' => $account->getChildObject()->getServerHash(), - 'from_create_date' => $fromDate->format('Y-m-d H:i:s'), - ) - ); - $dispatcherObject->process($connectorObj); - - $this->processResponseMessages($connectorObj->getResponseMessages()); - - return $connectorObj->getResponseData(); - } - - /** - * @param array $items - * @return void - * @throws Ess_M2ePro_Model_Exception_Logic - */ - protected function processOrderItems(array $items) - { - foreach ($items as $item) { - /** @var Ess_M2ePro_Model_Resource_Order_Item_Collection $collection */ - $collection = Mage::helper('M2ePro/Component_Walmart')->getCollection('Order_Item'); - $collection - ->addFieldToFilter('walmart_order_id', $item['walmart_order_id']) - ->addFieldToFilter('sku', $item['sku']); - $collection->getSelect()->join( - array( - 'wo' => Mage::getResourceModel('M2ePro/Walmart_Order')->getMainTable() - ), - 'main_table.order_id=wo.order_id', - array() - ); - - /** @var Ess_M2ePro_Model_Order_Item $existItem */ - $existItem = $collection->getFirstItem(); - - if (!$existItem->getId()) { - $this->_moduleLoggerHelper->process( - array( - 'walmart_order_id' => $item['walmart_order_id'], - 'sku' => $item['sku'], - ), - 'Walmart orders receive with cancellation requested task - cannot find order item' - ); - - continue; - } - - $cancellationRequestSavedPreviously = $existItem->getChildObject() - ->isBuyerCancellationRequested(); - if ($cancellationRequestSavedPreviously) { - continue; - } - - $existItem->getChildObject() - ->setData('buyer_cancellation_requested', 1) - ->save(); - - $this->notifyAboutBuyerCancellationRequested($existItem->getChildObject()); - } - } - - /** - * @param Ess_M2ePro_Model_Walmart_Order_Item $walmartOrderItem - * @return void - * @throws Ess_M2ePro_Model_Exception_Logic - */ - protected function notifyAboutBuyerCancellationRequested(Ess_M2ePro_Model_Walmart_Order_Item $walmartOrderItem) - { - $description = 'A buyer requested to cancel the item(s) "%item_name%" from the order #%order_number%.'; - - $walmartOrder = $walmartOrderItem->getWalmartOrder(); - $walmartOrder->getParentObject()->addWarningLog( - $description, - array( - '!order_number' => $walmartOrder->getWalmartOrderId(), - '!item_name' => $walmartOrderItem->getTitle() - ) - ); - } - - protected function processResponseMessages(array $messages = array()) - { - /** @var Ess_M2ePro_Model_Connector_Connection_Response_Message_Set $messagesSet */ - $messagesSet = Mage::getModel('M2ePro/Connector_Connection_Response_Message_Set'); - $messagesSet->init($messages); - - foreach ($messagesSet->getEntities() as $message) { - if (!$message->isError() && !$message->isWarning()) { - continue; - } - - if ($message->isError()) { - $this->_accountSynchronizationFail = true; - } - - $logType = $message->isError() ? Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR - : Ess_M2ePro_Model_Log_Abstract::TYPE_WARNING; - - $this->getSynchronizationLog()->addMessage( - $this->_dataHelper->__($message->getText()), - $logType - ); - } - } -} diff --git a/app/code/community/Ess/M2ePro/Model/Resource/Amazon/Listing/Product.php b/app/code/community/Ess/M2ePro/Model/Resource/Amazon/Listing/Product.php index 431359c8b..5405b06f4 100644 --- a/app/code/community/Ess/M2ePro/Model/Resource/Amazon/Listing/Product.php +++ b/app/code/community/Ess/M2ePro/Model/Resource/Amazon/Listing/Product.php @@ -9,6 +9,8 @@ class Ess_M2ePro_Model_Resource_Amazon_Listing_Product extends Ess_M2ePro_Model_Resource_Component_Child_Abstract { + const IS_STOPPED_MANUALLY_FIELD = 'is_stopped_manually'; + protected $_isPkAutoIncrement = false; //######################################## diff --git a/app/code/community/Ess/M2ePro/Model/Resource/Walmart/Listing/Product.php b/app/code/community/Ess/M2ePro/Model/Resource/Walmart/Listing/Product.php index 37362fc7a..73b27196f 100644 --- a/app/code/community/Ess/M2ePro/Model/Resource/Walmart/Listing/Product.php +++ b/app/code/community/Ess/M2ePro/Model/Resource/Walmart/Listing/Product.php @@ -9,6 +9,8 @@ class Ess_M2ePro_Model_Resource_Walmart_Listing_Product extends Ess_M2ePro_Model_Resource_Component_Child_Abstract { + const IS_STOPPED_MANUALLY_FIELD = 'is_stopped_manually'; + protected $_isPkAutoIncrement = false; //######################################## diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Connector/Orders/Get/ItemsCancellationRequested.php b/app/code/community/Ess/M2ePro/Model/Walmart/Connector/Orders/Get/ItemsCancellationRequested.php deleted file mode 100644 index ad5b54d19..000000000 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Connector/Orders/Get/ItemsCancellationRequested.php +++ /dev/null @@ -1,58 +0,0 @@ - $this->_params['account'], - 'from_create_date' => $this->_params['from_create_date'], - ); - } - - /** - * @return array - */ - protected function getCommand() - { - return array('orders', 'get', 'itemsCancellationRequested'); - } - - /** - * @return bool - */ - protected function validateResponse() - { - $responseData = $this->getResponse()->getData(); - - return isset($responseData['items']); - } - - /** - * @return void - */ - protected function prepareResponseData() - { - $result = array(); - $responseData = $this->getResponse()->getData(); - - foreach ($responseData['items'] as $item) { - $result[] = array( - 'sku' => $item['sku'], - 'walmart_order_id' => $item['walmart_order_id'], - ); - } - - $this->_responseData = $result; - } -} diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product.php b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product.php index 5cf46acaf..6a49a307c 100644 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product.php +++ b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product.php @@ -8,6 +8,7 @@ use Ess_M2ePro_Model_Listing_Product_PriceCalculator as PriceCalculator; use Ess_M2ePro_Model_Walmart_Template_SellingFormat_Promotion as Promotion; +use Ess_M2ePro_Model_Resource_Walmart_Listing_Product as Resource; /** * @method Ess_M2ePro_Model_Listing_Product getParentObject() @@ -475,6 +476,16 @@ public function getStatusChangeReasons() // --------------------------------------- + /** + * @return bool + */ + public function isStoppedManually() + { + return (bool)$this->getData(Resource::IS_STOPPED_MANUALLY_FIELD); + } + + // --------------------------------------- + /** * @return bool */ diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/List/Response.php b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/List/Response.php index c5f48a49f..b51b49312 100644 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/List/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/List/Response.php @@ -34,6 +34,7 @@ public function processSuccess($params = array()) $data = $this->appendPriceValues($data); $data = $this->appendDetailsValues($data); $data = $this->appendProductIdsData($data); + $data = $this->appendIsStoppedManually($data, false); $this->getListingProduct()->addData($data); $this->getListingProduct()->save(); diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/List/UpdateInventory/Response.php b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/List/UpdateInventory/Response.php index 78f526d34..d616016d4 100644 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/List/UpdateInventory/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/List/UpdateInventory/Response.php @@ -20,6 +20,8 @@ public function processSuccess($params = array()) $data = $this->appendQtyValues($data); $data = $this->appendLagTimeValues($data); + $data = $this->appendIsStoppedManually($data, false); + $this->getListingProduct()->addData($data); $this->setLastSynchronizationDates(); diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Relist/Response.php b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Relist/Response.php index a4fb9900d..bf3021376 100644 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Relist/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Relist/Response.php @@ -33,6 +33,7 @@ public function processSuccess($params = array()) $data = $this->appendLagTimeValues($data); $data = $this->appendPriceValues($data); $data = $this->appendPromotionsValues($data); + $data = $this->appendIsStoppedManually($data, false); $data = $this->processRecheckInstructions($data); diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Response.php b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Response.php index 336e4088e..98ef7e5c1 100644 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Response.php @@ -333,6 +333,17 @@ protected function appendProductIdsData($data) return $data; } + /** + * @param array $data + * @param bool $value + * @return array + */ + protected function appendIsStoppedManually($data, $value) + { + $data[Ess_M2ePro_Model_Resource_Walmart_Listing_Product::IS_STOPPED_MANUALLY_FIELD] = $value; + return $data; + } + //######################################## protected function setLastSynchronizationDates() diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Revise/Response.php b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Revise/Response.php index 1618e8f6a..273539b14 100644 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Revise/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Revise/Response.php @@ -38,6 +38,7 @@ public function processSuccess($params = array()) $data = $this->appendEndDate($data); $data = $this->appendChangedSku($data); $data = $this->appendProductIdsData($data); + $data = $this->appendIsStoppedManually($data, false); $this->getListingProduct()->addData($data); diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Stop/Response.php b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Stop/Response.php index 7d848f1eb..5364f0cfb 100644 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Stop/Response.php +++ b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Action/Type/Stop/Response.php @@ -24,6 +24,10 @@ public function processSuccess($params = array()) $data = $this->appendQtyValues($data); $data = $this->appendLagTimeValues($data); + $isStoppedManually = $this->getListingProduct()->isStopped() && $this->getListingProduct()->getStatusChanger() + === Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER; + $data = $this->appendIsStoppedManually($data, $isStoppedManually); + $this->getListingProduct()->addData($data); $this->setLastSynchronizationDates(); diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Instruction/SynchronizationTemplate/Checker/Inactive.php b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Instruction/SynchronizationTemplate/Checker/Inactive.php index b68b75d49..90cf18206 100644 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Instruction/SynchronizationTemplate/Checker/Inactive.php +++ b/app/code/community/Ess/M2ePro/Model/Walmart/Listing/Product/Instruction/SynchronizationTemplate/Checker/Inactive.php @@ -177,8 +177,10 @@ public function isMeetRelistRequirements() return false; } - if ($walmartSynchronizationTemplate->isRelistFilterUserLock() && - $listingProduct->getStatusChanger() == Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_USER) { + if ( + $walmartSynchronizationTemplate->isRelistFilterUserLock() + && $walmartListingProduct->isStoppedManually() + ) { return false; } diff --git a/app/code/community/Ess/M2ePro/Model/Walmart/Order/Action/Handler/Acknowledge.php b/app/code/community/Ess/M2ePro/Model/Walmart/Order/Action/Handler/Acknowledge.php index ba4500000..80527db9d 100644 --- a/app/code/community/Ess/M2ePro/Model/Walmart/Order/Action/Handler/Acknowledge.php +++ b/app/code/community/Ess/M2ePro/Model/Walmart/Order/Action/Handler/Acknowledge.php @@ -47,17 +47,6 @@ protected function processResult(array $responseData) return; } - $itemsStatuses = array(); - - foreach ($this->getOrder()->getItemsCollection() as $item) { - $item->setData('status', OrderItem::STATUS_ACKNOWLEDGED)->save(); - $itemsStatuses[$item->getData('walmart_order_item_id')] = OrderItem::STATUS_ACKNOWLEDGED; - } - - $orderStatus = Mage::getModel('M2ePro/Walmart_Order_Helper')->getOrderStatus($itemsStatuses); - $this->getOrder()->setData('status', $orderStatus); - $this->getOrder()->save(); - $this->getOrder()->addSuccessLog( Mage::helper('M2ePro')->__('Order was acknowledged.') ); diff --git a/app/code/community/Ess/M2ePro/composer.json b/app/code/community/Ess/M2ePro/composer.json index b4a7b6503..c2a1905e9 100644 --- a/app/code/community/Ess/M2ePro/composer.json +++ b/app/code/community/Ess/M2ePro/composer.json @@ -2,7 +2,7 @@ "name": "m2epro/magento1-extension", "description": "M2E Pro is a Magento trusted (TM), award-winning extension, which allows merchants of all sizes to fully integrate Magento based system(s) into eBay/Amazon/Walmart platforms.", "type": "magento-module", - "version": "6.37.1", + "version": "6.38.0", "license": "proprietary", "keywords": ["ebay", "amazon", "walmart", "magento"], "homepage": "https://www.m2epro.com/", diff --git a/app/code/community/Ess/M2ePro/etc/config.xml b/app/code/community/Ess/M2ePro/etc/config.xml index 2f3dbb0a3..e81cc6a86 100644 --- a/app/code/community/Ess/M2ePro/etc/config.xml +++ b/app/code/community/Ess/M2ePro/etc/config.xml @@ -2,7 +2,7 @@ - 6.37.1 + 6.38.0 diff --git a/app/code/community/Ess/M2ePro/sql/Install/Amazon.php b/app/code/community/Ess/M2ePro/sql/Install/Amazon.php index 81df9407a..8236569f9 100644 --- a/app/code/community/Ess/M2ePro/sql/Install/Amazon.php +++ b/app/code/community/Ess/M2ePro/sql/Install/Amazon.php @@ -321,6 +321,7 @@ public function execute() `is_afn_channel` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0, `is_isbn_general_id` TINYINT(2) UNSIGNED DEFAULT NULL, `is_general_id_owner` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0, + `is_stopped_manually` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0, `variation_parent_afn_state` SMALLINT(4) UNSIGNED DEFAULT NULL, `variation_parent_repricing_state` SMALLINT(4) UNSIGNED DEFAULT NULL, `defected_messages` TEXT DEFAULT NULL, diff --git a/app/code/community/Ess/M2ePro/sql/Install/Ebay.php b/app/code/community/Ess/M2ePro/sql/Install/Ebay.php index 94251360d..be40841ae 100644 --- a/app/code/community/Ess/M2ePro/sql/Install/Ebay.php +++ b/app/code/community/Ess/M2ePro/sql/Install/Ebay.php @@ -1107,7 +1107,7 @@ public function execute() (18, 'MYR', 'my', 'ms_MY', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), (19, 'CAD', 'ca', 'fr_CA', 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0), (20, 'PHP', 'ph', 'fil_PH', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), - (21, 'PLN', 'pl', 'pl_PL', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), + (21, 'PLN', 'pl', 'pl_PL', 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), (22, 'SGD', 'sg', 'zh_SG', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0); SQL diff --git a/app/code/community/Ess/M2ePro/sql/Install/Walmart.php b/app/code/community/Ess/M2ePro/sql/Install/Walmart.php index ef13064df..385463de6 100644 --- a/app/code/community/Ess/M2ePro/sql/Install/Walmart.php +++ b/app/code/community/Ess/M2ePro/sql/Install/Walmart.php @@ -227,6 +227,7 @@ public function execute() `publish_status` VARCHAR(255) DEFAULT NULL, `lifecycle_status` VARCHAR(255) DEFAULT NULL, `status_change_reasons` TEXT DEFAULT NULL, + `is_stopped_manually` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0, `online_price` DECIMAL(12, 4) UNSIGNED DEFAULT NULL, `is_online_price_invalid` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0, `online_promotions` VARCHAR(40) DEFAULT NULL, diff --git a/app/code/community/Ess/M2ePro/sql/Update/y23_m03/AddColumnIsStoppedManuallyForAmazonAndWalmartProducts.php b/app/code/community/Ess/M2ePro/sql/Update/y23_m03/AddColumnIsStoppedManuallyForAmazonAndWalmartProducts.php new file mode 100644 index 000000000..eba7977e1 --- /dev/null +++ b/app/code/community/Ess/M2ePro/sql/Update/y23_m03/AddColumnIsStoppedManuallyForAmazonAndWalmartProducts.php @@ -0,0 +1,31 @@ +modifyTable('amazon_listing_product', 'is_general_id_owner'); + $this->modifyTable('walmart_listing_product', 'status_change_reasons'); + } + + /** + * @param string $tableName + * @param string $afterColumn + * @return void + * @throws Ess_M2ePro_Model_Exception_Setup + * @throws Zend_Db_Exception + */ + private function modifyTable($tableName, $afterColumn) + { + $tableModifier = $this->_installer->getTableModifier($tableName); + $tableModifier->addColumn('is_stopped_manually', 'TINYINT(2) UNSIGNED NOT NULL', 0, $afterColumn); + } +} diff --git a/app/code/community/Ess/M2ePro/sql/Update/y23_m04/SetIsVatEbayMarketplacePL.php b/app/code/community/Ess/M2ePro/sql/Update/y23_m04/SetIsVatEbayMarketplacePL.php new file mode 100644 index 000000000..e3c71051c --- /dev/null +++ b/app/code/community/Ess/M2ePro/sql/Update/y23_m04/SetIsVatEbayMarketplacePL.php @@ -0,0 +1,17 @@ +_installer->getFullTableName('ebay_marketplace'); + $this->_installer->getConnection()->update( + $ebayMarketplaceTable, + array('is_vat' => 1), + 'marketplace_id = 21' + ); + } +} diff --git a/app/code/community/Ess/M2ePro/sql/Upgrade/v6_37_1__v6_38_0/Config.php b/app/code/community/Ess/M2ePro/sql/Upgrade/v6_37_1__v6_38_0/Config.php new file mode 100644 index 000000000..ee6eb500d --- /dev/null +++ b/app/code/community/Ess/M2ePro/sql/Upgrade/v6_37_1__v6_38_0/Config.php @@ -0,0 +1,17 @@ +