Skip to content

Commit dedbe33

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-56063-upgrade-from-2.0.7-to-2.1.0
2 parents ecf5109 + 37692c8 commit dedbe33

File tree

45 files changed

+1586
-188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1586
-188
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public function execute()
9797
$productTypeId = $this->getRequest()->getParam('type');
9898
if ($data) {
9999
try {
100+
$this->unserializeProductData($data);
100101
$product = $this->initializationHelper->initialize(
101102
$this->productBuilder->build($this->getRequest())
102103
);
@@ -180,6 +181,30 @@ public function execute()
180181
return $resultRedirect;
181182
}
182183

184+
/**
185+
* Unserialize product data for configurable products
186+
*
187+
* @param array $postData
188+
* @return void
189+
*/
190+
private function unserializeProductData($postData)
191+
{
192+
if (isset($postData["configurable-matrix-serialized"])) {
193+
$configurableMatrixSerialized = $postData["configurable-matrix-serialized"];
194+
if ($configurableMatrixSerialized != null && !empty($configurableMatrixSerialized)) {
195+
$postData["configurable-matrix"] = json_decode($configurableMatrixSerialized, true);
196+
unset($postData["configurable-matrix-serialized"]);
197+
}
198+
}
199+
if (isset($postData["associated_product_ids_serialized"])) {
200+
$associatedProductIdsSerialized = $postData["associated_product_ids_serialized"];
201+
if ($associatedProductIdsSerialized != null && !empty($associatedProductIdsSerialized)) {
202+
$postData["associated_product_ids"] = json_decode($associatedProductIdsSerialized, true);
203+
unset($postData["associated_product_ids_serialized"]);
204+
}
205+
}
206+
}
207+
183208
/**
184209
* Notify customer when image was not deleted in specific case.
185210
* TODO: temporary workaround must be eliminated in MAGETWO-45306

app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
</div>
4141
</div>
4242
<?php endif; ?>
43+
<?php if ($block->isRedirectToCartEnabled()) : ?>
4344
<script type="text/x-magento-init">
4445
{
4546
"#product_addtocart_form": {
@@ -49,11 +50,11 @@
4950
}
5051
}
5152
</script>
52-
<?php if (!$block->isRedirectToCartEnabled()) : ?>
53+
<?php else : ?>
5354
<script type="text/x-magento-init">
5455
{
5556
"#product_addtocart_form": {
56-
"catalogAddToCart": {}
57+
"Magento_Catalog/js/validate-product": {}
5758
}
5859
}
5960
</script>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright © 2016 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'jquery',
7+
'mage/mage',
8+
'Magento_Catalog/product/view/validation',
9+
'catalogAddToCart'
10+
], function ($) {
11+
'use strict';
12+
13+
$.widget('mage.productValidate', {
14+
options: {
15+
bindSubmit: false,
16+
radioCheckboxClosest: '.nested'
17+
},
18+
19+
/**
20+
* Uses Magento's validation widget for the form object.
21+
* @private
22+
*/
23+
_create: function () {
24+
var bindSubmit = this.options.bindSubmit;
25+
26+
this.element.validation({
27+
radioCheckboxClosest: this.options.radioCheckboxClosest,
28+
29+
/**
30+
* Uses catalogAddToCart widget as submit handler.
31+
* @param {Object} form
32+
* @returns {Boolean}
33+
*/
34+
submitHandler: function (form) {
35+
var jqForm = $(form).catalogAddToCart({
36+
bindSubmit: bindSubmit
37+
});
38+
39+
jqForm.catalogAddToCart('submitForm', jqForm);
40+
41+
return false;
42+
}
43+
});
44+
}
45+
});
46+
47+
return $.mage.productValidate;
48+
});

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ public function afterInitialize(Helper $subject, ProductInterface $product)
127127
*/
128128
private function setLinkedProducts(ProductInterface $product, ProductExtensionInterface $extensionAttributes)
129129
{
130-
$associatedProductIds = $this->request->getPost('associated_product_ids', []);
130+
$associatedProductIds = $this->request->getPost('associated_product_ids_serialized', '[]');
131+
if ($associatedProductIds != null && !empty($associatedProductIds)) {
132+
$associatedProductIds = json_decode($associatedProductIds, true);
133+
}
134+
131135
$variationsMatrix = $this->getVariationMatrix();
132136

133137
if ($associatedProductIds || $variationsMatrix) {
@@ -149,7 +153,10 @@ private function setLinkedProducts(ProductInterface $product, ProductExtensionIn
149153
protected function getVariationMatrix()
150154
{
151155
$result = [];
152-
$configurableMatrix = $this->request->getParam('configurable-matrix', []);
156+
$configurableMatrix = $this->request->getParam('configurable-matrix-serialized', '[]');
157+
if ($configurableMatrix != null && !empty($configurableMatrix)) {
158+
$configurableMatrix = json_decode($configurableMatrix, true);
159+
}
153160

154161
foreach ($configurableMatrix as $item) {
155162
if ($item['newProduct']) {

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ public function afterInitialize(
8585
protected function getConfigurations()
8686
{
8787
$result = [];
88-
$configurableMatrix = $this->request->getParam('configurable-matrix', []);
88+
$configurableMatrix = $this->request->getParam('configurable-matrix-serialized', '[]');
89+
if ($configurableMatrix != null && !empty($configurableMatrix)) {
90+
$configurableMatrix = json_decode($configurableMatrix, true);
91+
}
92+
8993
foreach ($configurableMatrix as $item) {
9094
if (!$item['newProduct']) {
9195
$result[$item['id']] = $this->mapData($item);

app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testAfterInitializeWithAttributesAndVariations()
101101
];
102102
$valueMap = [
103103
['new-variations-attribute-set-id', null, 24],
104-
['associated_product_ids', [], []],
104+
['associated_product_ids_serialized', '[]', []],
105105
['product', [], ['configurable_attributes_data' => $attributes]],
106106
];
107107
$simpleProductsIds = [1, 2, 3];
@@ -150,7 +150,7 @@ public function testAfterInitializeWithAttributesAndVariations()
150150
]
151151
];
152152
$paramValueMap = [
153-
['configurable-matrix', [], $simpleProducts],
153+
['configurable-matrix-serialized', '[]', json_encode($simpleProducts)],
154154
['attributes', null, $attributes],
155155
];
156156

@@ -212,11 +212,11 @@ public function testAfterInitializeWithAttributesAndWithoutVariations()
212212
];
213213
$valueMap = [
214214
['new-variations-attribute-set-id', null, 24],
215-
['associated_product_ids', [], []],
215+
['associated_product_ids_serialized', '[]', []],
216216
['product', [], ['configurable_attributes_data' => $attributes]],
217217
];
218218
$paramValueMap = [
219-
['configurable-matrix', [], []],
219+
['configurable-matrix-serialized', '[]', []],
220220
['attributes', null, $attributes],
221221
];
222222

app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function testAfterInitialize()
127127
->willReturnMap(
128128
[
129129
['store', 0, 0],
130-
['configurable-matrix', [], $configurableMatrix]
130+
['configurable-matrix-serialized', '[]', json_encode($configurableMatrix)]
131131
]
132132
);
133133
$this->variationHandlerMock->expects(static::once())

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ define([
301301
* Chose action for the form save button
302302
*/
303303
saveFormHandler: function() {
304+
this.source.data["configurable-matrix-serialized"] =
305+
JSON.stringify(this.source.data["configurable-matrix"]);
306+
delete this.source.data["configurable-matrix"];
307+
this.source.data["associated_product_ids_serialized"] =
308+
JSON.stringify(this.source.data["associated_product_ids"]);
309+
delete this.source.data["associated_product_ids"];
304310
if (this.checkForNewAttributes()) {
305311
this.formSaveParams = arguments;
306312
this.attributeSetHandlerModal().openModal();

app/code/Magento/Customer/Model/Authentication.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@
66
namespace Magento\Customer\Model;
77

88
use Magento\Customer\Api\CustomerRepositoryInterface;
9+
use Magento\Customer\Model\ResourceModel\CustomerRepository;
10+
use Magento\Customer\Model\CustomerAuthUpdate;
911
use Magento\Backend\App\ConfigInterface;
1012
use Magento\Framework\Encryption\EncryptorInterface as Encryptor;
1113
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
1214
use Magento\Framework\Exception\State\UserLockedException;
1315

16+
/**
17+
* Class Authentication
18+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
19+
*/
1420
class Authentication implements AuthenticationInterface
1521
{
1622
/**
@@ -50,6 +56,11 @@ class Authentication implements AuthenticationInterface
5056
*/
5157
protected $customerRepository;
5258

59+
/**
60+
* @var CustomerAuthUpdate
61+
*/
62+
private $customerAuthUpdate;
63+
5364
/**
5465
* @param CustomerRepositoryInterface $customerRepository
5566
* @param CustomerRegistry $customerRegistry
@@ -105,7 +116,7 @@ public function processAuthenticationFailure($customerId)
105116
}
106117

107118
$customerSecure->setFailuresNum($failuresNum);
108-
$this->customerRepository->save($this->customerRepository->getById($customerId));
119+
$this->getCustomerAuthUpdate()->saveAuth($customerId);
109120
}
110121

111122
/**
@@ -117,7 +128,7 @@ public function unlock($customerId)
117128
$customerSecure->setFailuresNum(0);
118129
$customerSecure->setFirstFailure(null);
119130
$customerSecure->setLockExpires(null);
120-
$this->customerRepository->save($this->customerRepository->getById($customerId));
131+
$this->getCustomerAuthUpdate()->saveAuth($customerId);
121132
}
122133

123134
/**
@@ -165,4 +176,19 @@ public function authenticate($customerId, $password)
165176
}
166177
return true;
167178
}
179+
180+
/**
181+
* Get customer authentication update model
182+
*
183+
* @return \Magento\Customer\Model\CustomerAuthUpdate
184+
* @deprecated
185+
*/
186+
private function getCustomerAuthUpdate()
187+
{
188+
if ($this->customerAuthUpdate === null) {
189+
$this->customerAuthUpdate =
190+
\Magento\Framework\App\ObjectManager::getInstance()->get(CustomerAuthUpdate::class);
191+
}
192+
return $this->customerAuthUpdate;
193+
}
168194
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Model;
8+
9+
/**
10+
* Customer Authentication update model.
11+
*/
12+
class CustomerAuthUpdate
13+
{
14+
/**
15+
* @var \Magento\Customer\Model\CustomerRegistry
16+
*/
17+
protected $customerRegistry;
18+
19+
/**
20+
* @var \Magento\Customer\Model\ResourceModel\Customer
21+
*/
22+
protected $customerResourceModel;
23+
24+
/**
25+
* @param \Magento\Customer\Model\CustomerRegistry $customerRegistry
26+
* @param \Magento\Customer\Model\ResourceModel\Customer $customerResourceModel
27+
*/
28+
public function __construct(
29+
\Magento\Customer\Model\CustomerRegistry $customerRegistry,
30+
\Magento\Customer\Model\ResourceModel\Customer $customerResourceModel
31+
) {
32+
$this->customerRegistry = $customerRegistry;
33+
$this->customerResourceModel = $customerResourceModel;
34+
}
35+
36+
/**
37+
* Reset Authentication data for customer.
38+
*
39+
* @param int $customerId
40+
* @return $this
41+
*/
42+
public function saveAuth($customerId)
43+
{
44+
$customerSecure = $this->customerRegistry->retrieveSecureData($customerId);
45+
46+
$this->customerResourceModel->getConnection()->update(
47+
$this->customerResourceModel->getTable('customer_entity'),
48+
[
49+
'failures_num' => $customerSecure->getData('failures_num'),
50+
'first_failure' => $customerSecure->getData('first_failure'),
51+
'lock_expires' => $customerSecure->getData('lock_expires'),
52+
],
53+
$this->customerResourceModel->getConnection()->quoteInto('entity_id = ?', $customerId)
54+
);
55+
56+
return $this;
57+
}
58+
}

0 commit comments

Comments
 (0)