Skip to content

Commit

Permalink
Merge pull request #641 from magento-south/BUGS-2.0
Browse files Browse the repository at this point in the history
[South] Bugs 2.0:
- MAGETWO-61178 Inconsistent sales_order_item information after upgrade
- MAGETWO-61232 Shipping rates can not be loaded
- MAGETWO-61249 [Backport] Loader doesn't disappear after click on 'Place Order' button - for 2.0
  • Loading branch information
slavvka authored Dec 1, 2016
2 parents 29c17ce + c7a5c70 commit 6b486f7
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected function placeCheckoutOrder()
);
} catch (\Exception $exception) {
$result->setData('error', true);
$result->setData('error_messages', __('Cannot place order.'));
$result->setData('error_messages', __('Unable to place order. Please try again later.'));
}
if ($response instanceof Http) {
$response->representJson($this->jsonHelper->jsonEncode($result));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function textExecuteFailedPlaceOrderDataProvider()
{
$objectFailed = new \Magento\Framework\DataObject();
$objectFailed->setData('error', true);
$objectFailed->setData('error_messages', __('Cannot place order.'));
$objectFailed->setData('error_messages', __('Unable to place order. Please try again later.'));

return [
[
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Authorizenet/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Cancel,Cancel
"Something went wrong canceling the transactions.","Something went wrong canceling the transactions."
"There was an error canceling transactions. Please contact us or try again later.","There was an error canceling transactions. Please contact us or try again later."
"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later."
"Unable to place order. Please try again later.","Unable to place order. Please try again later."
"amount %1","amount %1"
failed,failed
successful,successful
Expand Down
16 changes: 9 additions & 7 deletions app/code/Magento/Customer/Model/Address/AbstractAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function setData($key, $value = null)
{
if (is_array($key)) {
$key = $this->_implodeArrayField($key);
} elseif (is_array($value) && !empty($value) && $this->isAddressMultilineAttribute($key)) {
} elseif (is_array($value) && $this->isAddressMultilineAttribute($key)) {
$value = $this->_implodeArrayValues($value);
}
return parent::setData($key, $value);
Expand Down Expand Up @@ -291,7 +291,7 @@ protected function isAddressMultilineAttribute($code)
protected function _implodeArrayField(array $data)
{
foreach ($data as $key => $value) {
if (is_array($value) && !empty($value) && $this->isAddressMultilineAttribute($key)) {
if (is_array($value) && $this->isAddressMultilineAttribute($key)) {
$data[$key] = $this->_implodeArrayValues($data[$key]);
}
}
Expand All @@ -301,22 +301,24 @@ protected function _implodeArrayField(array $data)
/**
* Combine values of field lines into a single string
*
* @param string[]|string $value
* @param array $value
* @return string
*/
protected function _implodeArrayValues($value)
{
if (is_array($value) && count($value)) {
$isScalar = false;
if (is_array($value)) {
$isScalar = true;
foreach ($value as $val) {
if (is_scalar($val)) {
$isScalar = true;
if (!is_scalar($val)) {
$isScalar = false;
}
}

if ($isScalar) {
$value = trim(implode("\n", $value));
}
}

return $value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,24 @@ define(
var self = this;

if (this.validateHandler() && additionalValidators.validate()) {
fullScreenLoader.startLoader();
this.isPlaceOrderActionAllowed(false);
$.when(setPaymentInformationAction(this.messageContainer, {
'method': self.getCode()
})).done(function () {
self.placeOrderHandler().fail(function () {
fullScreenLoader.startLoader();
$.when(
setPaymentInformationAction(this.messageContainer, {'method': self.getCode()})
).done(
function () {
self.placeOrderHandler().fail(
function () {
fullScreenLoader.stopLoader();
}
);
}
).always(
function () {
self.isPlaceOrderActionAllowed(true);
fullScreenLoader.stopLoader();
});
}).fail(function () {
fullScreenLoader.stopLoader();
self.isPlaceOrderActionAllowed(true);
});
}
);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Quote/Model/QuoteManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
$order = $this->submit($quote);

if (null == $order) {
throw new LocalizedException(__('Cannot place order.'));
throw new LocalizedException(__('Unable to place order. Please try again later.'));
}

$this->checkoutSession->setLastQuoteId($quote->getId());
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Quote/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Shipping,Shipping
"Please specify a shipping method.","Please specify a shipping method."
"Please check the billing address information. %1","Please check the billing address information. %1"
"Please select a valid payment method.","Please select a valid payment method."
"Unable to place order. Please try again later.","Unable to place order. Please try again later."
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ protected function _afterLoad()
* Assign parent items
*/
foreach ($this as $item) {
$this->_resource->unserializeFields($item);
if ($item->getParentItemId()) {
$item->setParentItem($this->getItemById($item->getParentItemId()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,13 @@ protected function _afterLoad()
parent::_afterLoad();
foreach ($this->_items as $item) {
$item->setOrigData();
if ($this->_resetItemsDataChanged && ($item instanceof \Magento\Framework\Model\AbstractModel)) {
$item->setDataChanges(false);

if ($item instanceof \Magento\Framework\Model\AbstractModel) {
$this->getResource()->unserializeFields($item);

if ($this->_resetItemsDataChanged) {
$item->setDataChanges(false);
}
}
}
$this->_eventManager->dispatch('core_collection_abstract_load_after', ['collection' => $this]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Magento\Framework\Model\Test\Unit\ResourceModel\Db\Collection;

use Magento\Framework\DB\Select;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Framework\DataObject as MagentoObject;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
Expand Down Expand Up @@ -257,6 +258,30 @@ public function addFieldToSelectDataProvider()
];
}

public function testLoadWithItemFieldsUnserialization()
{
$itemMock = $this->getMockBuilder(AbstractModel::class)
->disableOriginalConstructor()
->getMock();
$this->uut->addItem($itemMock);

$itemMock->expects($this->once())
->method('setOrigData');
$this->resourceMock->expects($this->once())
->method('unserializeFields')
->with($itemMock);

$this->managerMock->expects($this->exactly(2))
->method('dispatch')
->withConsecutive(
['core_collection_abstract_load_before', ['collection' => $this->uut]],
['core_collection_abstract_load_after', ['collection' => $this->uut]]

);

$this->uut->load();
}

/**
* @dataProvider addExpressionFieldToSelectDataProvider
*/
Expand Down

0 comments on commit 6b486f7

Please sign in to comment.