From dd62ddd5cc9672decd0823fe3dde9a804cd2aba3 Mon Sep 17 00:00:00 2001 From: M2E Pro Date: Thu, 30 Sep 2021 12:56:49 +0000 Subject: [PATCH] 6.14.2 (FINAL RELEASE) --- app/code/community/Ess/M2ePro/CHANGELOG | 10 ++++++++- .../Account/Update/EntityRequester.php | 11 +++++++++- .../Cron/Task/Amazon/Order/SendInvoice.php | 17 +++++++++++++-- .../Model/Cron/Task/Ebay/Order/Refund.php | 2 +- .../Model/Cron/Task/Ebay/Order/Update.php | 3 +++ .../Ess/M2ePro/Model/Ebay/Order/Builder.php | 2 +- .../Ess/M2ePro/Model/Ebay/Order/Proxy.php | 2 +- .../Ess/M2ePro/Model/Magento/Quote.php | 5 +---- .../Ess/M2ePro/Model/Magento/Quote/Item.php | 21 ++++++++++--------- app/code/community/Ess/M2ePro/composer.json | 2 +- app/code/community/Ess/M2ePro/etc/config.xml | 2 +- .../sql/Upgrade/v6_14_1__v6_14_2/Config.php | 19 +++++++++++++++++ composer.json | 2 +- 13 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 app/code/community/Ess/M2ePro/sql/Upgrade/v6_14_1__v6_14_2/Config.php diff --git a/app/code/community/Ess/M2ePro/CHANGELOG b/app/code/community/Ess/M2ePro/CHANGELOG index 0484e44af..082ca393c 100644 --- a/app/code/community/Ess/M2ePro/CHANGELOG +++ b/app/code/community/Ess/M2ePro/CHANGELOG @@ -1,4 +1,12 @@ -* 6.14.1 (r16362) (14/07/2021) +* 6.14.2 (30/09/2021) + +[eBay] [Fixed] eBay order was not refunded as per Magento credit memo creation [#1220] +[eBay] [Fixed] Magento Order was not created. Reason: Warning: A non-numeric value encountered [#2594] +[Amazon] [Fixed] Different Grand Totals in Amazon and Magento orders for Grouped Products listed as Set [#1218] +[Amazon] [Fixed] Internal Server Error(s) [Marketplace ID is not valid. It differs from the current.] occurs when trying to update the MWS token [#1215] +[Amazon] [Improved] Self-upload of Amazon invoices without receiving and checking the results of the GetFeedSubmissionResult command [#2939] + +* 6.14.1 (r16362) (14/07/2021) [Common] [Improved] Display shipping service in the beginning of the line in Magento Orders [M1-1354] [Ebay] [Fixed] Magento Order was not created. Reason: Notice: Undefined index: delivery_date [M1-1361] diff --git a/app/code/community/Ess/M2ePro/Model/Amazon/Connector/Account/Update/EntityRequester.php b/app/code/community/Ess/M2ePro/Model/Amazon/Connector/Account/Update/EntityRequester.php index 663fd2ea9..31d60d23d 100644 --- a/app/code/community/Ess/M2ePro/Model/Amazon/Connector/Account/Update/EntityRequester.php +++ b/app/code/community/Ess/M2ePro/Model/Amazon/Connector/Account/Update/EntityRequester.php @@ -13,7 +13,16 @@ class Ess_M2ePro_Model_Amazon_Connector_Account_Update_EntityRequester public function getRequestData() { - return $this->_params; + /** @var $marketplaceObject Ess_M2ePro_Model_Marketplace */ + $marketplaceObject = Mage::helper('M2ePro/Component_Amazon')->getCachedObject( + 'Marketplace', $this->_params['marketplace_id'] + ); + + return array( + 'merchant_id' => $this->_params['merchant_id'], + 'token' => $this->_params['token'], + 'marketplace_id' => $marketplaceObject->getNativeId(), + ); } protected function getCommand() diff --git a/app/code/community/Ess/M2ePro/Model/Cron/Task/Amazon/Order/SendInvoice.php b/app/code/community/Ess/M2ePro/Model/Cron/Task/Amazon/Order/SendInvoice.php index c3cf15212..e144ecad6 100644 --- a/app/code/community/Ess/M2ePro/Model/Cron/Task/Amazon/Order/SendInvoice.php +++ b/app/code/community/Ess/M2ePro/Model/Cron/Task/Amazon/Order/SendInvoice.php @@ -14,7 +14,14 @@ class Ess_M2ePro_Model_Cron_Task_Amazon_Order_SendInvoice extends Ess_M2ePro_Model_Cron_Task_Abstract { const NICK = 'amazon/order/send_invoice'; - const ORDER_CHANGES_PER_ACCOUNT = 100; + + /** ~4-10 seconds on call, ~5-10 invoices per minute, 50 requests in 10 minutes */ + const LIMIT_ORDER_CHANGES = 50; + + /** @var int $_interval (in seconds) */ + protected $_interval = 600; + + protected $_maxOrderChangesPerTask = 0; //#################################### @@ -56,6 +63,10 @@ protected function performActions() foreach ($permittedAccounts as $account) { /** @var Ess_M2ePro_Model_Account $account */ + if ($this->_maxOrderChangesPerTask === self::LIMIT_ORDER_CHANGES) { + break; + } + $this->getOperationHistory()->addText('Starting account "' . $account->getTitle() . '"'); $this->getOperationHistory()->addTimePoint( @@ -399,9 +410,11 @@ protected function getRelatedChanges(Ess_M2ePro_Model_Account $account) array() ); $changesCollection->addFieldToFilter('pl.id', array('null' => true)); - $changesCollection->getSelect()->limit(self::ORDER_CHANGES_PER_ACCOUNT); + $changesCollection->getSelect()->limit(self::LIMIT_ORDER_CHANGES); $changesCollection->getSelect()->group(array('order_id')); + $this->_maxOrderChangesPerTask += $changesCollection->count(); + return $changesCollection->getItems(); } diff --git a/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Refund.php b/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Refund.php index e01d9ba3a..1792c1cb8 100644 --- a/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Refund.php +++ b/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Refund.php @@ -129,7 +129,7 @@ protected function processAccount(Ess_M2ePro_Model_Account $account) ); $dispatcherObject->process($connectorObj); - $cancelResponseData = $connectorObj->getRequestData(); + $cancelResponseData = $connectorObj->getResponseData(); if (!$cancelResponseData['result'] && $cancelResponseData['cancelId'] === null) { continue; diff --git a/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Update.php b/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Update.php index 801d9c61f..1949248b2 100644 --- a/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Update.php +++ b/app/code/community/Ess/M2ePro/Model/Cron/Task/Ebay/Order/Update.php @@ -5,6 +5,7 @@ * @copyright M2E LTD * @license Commercial use is forbidden */ +use Ess_M2ePro_Model_Order_Change as Change; class Ess_M2ePro_Model_Cron_Task_Ebay_Order_Update extends Ess_M2ePro_Model_Cron_Task_Abstract { @@ -101,6 +102,8 @@ protected function getRelatedChanges(Ess_M2ePro_Model_Account $account) $changesCollection = Mage::getModel('M2ePro/Order_Change')->getCollection(); $changesCollection->addAccountFilter($account->getId()); $changesCollection->addProcessingAttemptDateFilter(); + $changesCollection->addFieldToFilter('action', ['in' => [Change::ACTION_UPDATE_SHIPPING, + Change::ACTION_UPDATE_PAYMENT]]); $changesCollection->setPageSize(self::MAX_UPDATES_PER_TIME); $changesCollection->getSelect()->group(array('order_id')); diff --git a/app/code/community/Ess/M2ePro/Model/Ebay/Order/Builder.php b/app/code/community/Ess/M2ePro/Model/Ebay/Order/Builder.php index c9e033b23..02a38f2ab 100644 --- a/app/code/community/Ess/M2ePro/Model/Ebay/Order/Builder.php +++ b/app/code/community/Ess/M2ePro/Model/Ebay/Order/Builder.php @@ -807,7 +807,7 @@ protected function hasUpdatedCancellationStatus() $oldStatus = $this->_order->getChildObject()->getData('cancellation_status'); $newStatus = $this->getData('cancellation_status'); - if ($newStatus == 0 && ($oldStatus != $newStatus)) { + if ($newStatus == 1 && ($oldStatus != $newStatus)) { return true; } diff --git a/app/code/community/Ess/M2ePro/Model/Ebay/Order/Proxy.php b/app/code/community/Ess/M2ePro/Model/Ebay/Order/Proxy.php index e21ed7a29..0bcfd780b 100644 --- a/app/code/community/Ess/M2ePro/Model/Ebay/Order/Proxy.php +++ b/app/code/community/Ess/M2ePro/Model/Ebay/Order/Proxy.php @@ -358,7 +358,7 @@ protected function getShippingPrice() { if ($this->_order->isUseGlobalShippingProgram()) { $globalShippingDetails = $this->_order->getGlobalShippingDetails(); - $price = $globalShippingDetails['service_details']['price']; + $price = (float)$globalShippingDetails['service_details']['price']; } else { $price = $this->_order->getShippingPrice(); } diff --git a/app/code/community/Ess/M2ePro/Model/Magento/Quote.php b/app/code/community/Ess/M2ePro/Model/Magento/Quote.php index f45c27bec..3fb8dc871 100644 --- a/app/code/community/Ess/M2ePro/Model/Magento/Quote.php +++ b/app/code/community/Ess/M2ePro/Model/Magento/Quote.php @@ -282,21 +282,18 @@ protected function initializeQuoteItems() // --------------------------------------- foreach ($products as $associatedProduct) { - $item->setQty($associatedProduct->getQty() * $item->getOriginalQty()); $productPriceInSetPercent = ($associatedProduct->getPrice() / $totalPrice) * 100; $productPriceInItem = (($item->getOriginalPrice() * $productPriceInSetPercent) / 100); $item->setPrice($productPriceInItem / $associatedProduct->getQty()); - $associatedProduct->setTaxClassId($product->getTaxClassId()); - $quoteItemBuilder->init($this->_quote, $item); $this->initializeQuoteItem( $item, $quoteItemBuilder, - $associatedProduct, + $quoteItemBuilder->setTaxClassIntoProduct($associatedProduct), $quoteItemBuilder->getRequest() ); } diff --git a/app/code/community/Ess/M2ePro/Model/Magento/Quote/Item.php b/app/code/community/Ess/M2ePro/Model/Magento/Quote/Item.php index 53fd46f09..36761d476 100644 --- a/app/code/community/Ess/M2ePro/Model/Magento/Quote/Item.php +++ b/app/code/community/Ess/M2ePro/Model/Magento/Quote/Item.php @@ -57,9 +57,7 @@ public function getProduct() } // tax class id should be set before price calculation - $this->_product->setTaxClassId($this->getProductTaxClassId()); - - return $this->_product; + return $this->setTaxClassIntoProduct($this->_product); } // --------------------------------------- @@ -78,7 +76,10 @@ protected function getAssociatedGroupedProduct() //######################################## - protected function getProductTaxClassId() + /** + * @return Mage_Catalog_Model_Product + */ + public function setTaxClassIntoProduct(Mage_Catalog_Model_Product $product) { $proxyOrder = $this->_proxyItem->getProxyOrder(); $itemTaxRate = $this->_proxyItem->getTaxRate(); @@ -93,14 +94,14 @@ protected function getProductTaxClassId() || ($proxyOrder->isTaxModeMagento() && !$hasRatesForCountry && !$calculationBasedOnOrigin) || ($proxyOrder->isTaxModeMixed() && $itemTaxRate <= 0 && $isOrderHasTax) ) { - return Ess_M2ePro_Model_Magento_Product::TAX_CLASS_ID_NONE; + return $product->setTaxClassId(Ess_M2ePro_Model_Magento_Product::TAX_CLASS_ID_NONE); } if ($proxyOrder->isTaxModeMagento() || $itemTaxRate <= 0 - || $itemTaxRate == $this->getProductTaxRate() + || $itemTaxRate == $this->getProductTaxRate($product->getTaxClassId()) ) { - return $this->getProduct()->getTaxClassId(); + return $product; } // Create tax rule according to channel tax rate @@ -117,10 +118,10 @@ protected function getProductTaxClassId() $productTaxClasses = $taxRule->getProductTaxClasses(); // --------------------------------------- - return array_shift($productTaxClasses); + return $product->setTaxClassId(array_shift($productTaxClasses)); } - protected function getProductTaxRate() + protected function getProductTaxRate($productTaxClassId) { /** @var $taxCalculator Mage_Tax_Model_Calculation */ $taxCalculator = Mage::getSingleton('tax/calculation'); @@ -131,7 +132,7 @@ protected function getProductTaxRate() $this->_quote->getCustomerTaxClassId(), $this->_quote->getStore() ); - $request->setProductClassId($this->getProduct()->getTaxClassId()); + $request->setProductClassId($productTaxClassId); return $taxCalculator->getRate($request); } diff --git a/app/code/community/Ess/M2ePro/composer.json b/app/code/community/Ess/M2ePro/composer.json index acb80fda1..ba0f8babd 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.14.1", + "version": "6.14.2", "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 3f7880e49..03be6b5b7 100644 --- a/app/code/community/Ess/M2ePro/etc/config.xml +++ b/app/code/community/Ess/M2ePro/etc/config.xml @@ -2,7 +2,7 @@ - 6.14.1 + 6.14.2 diff --git a/app/code/community/Ess/M2ePro/sql/Upgrade/v6_14_1__v6_14_2/Config.php b/app/code/community/Ess/M2ePro/sql/Upgrade/v6_14_1__v6_14_2/Config.php new file mode 100644 index 000000000..cfca7b162 --- /dev/null +++ b/app/code/community/Ess/M2ePro/sql/Upgrade/v6_14_1__v6_14_2/Config.php @@ -0,0 +1,19 @@ +