Skip to content

Commit 4db2f5e

Browse files
committed
Merge branch '2.0' of https://github.com/magento/magento2ce into MPI-PR-2.0
2 parents 1950ba1 + a8abd0a commit 4db2f5e

File tree

112 files changed

+7724
-457
lines changed

Some content is hidden

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

112 files changed

+7724
-457
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function execute()
7373
$productTypeId = $this->getRequest()->getParam('type');
7474
if ($data) {
7575
try {
76+
$data = $this->unserializeData($data);
7677
$product = $this->initializationHelper->initialize($this->productBuilder->build($this->getRequest()));
7778
$this->productTypeManager->processProduct($product);
7879

@@ -157,6 +158,29 @@ public function execute()
157158
return $resultRedirect;
158159
}
159160

161+
/**
162+
* @param array $data
163+
* @return array
164+
*/
165+
private function unserializeData($data)
166+
{
167+
if (isset($data["configurable-matrix-serialized"])) {
168+
$configurableMatrixSerialized = $data["configurable-matrix-serialized"];
169+
if ($configurableMatrixSerialized != null && !empty($configurableMatrixSerialized)) {
170+
$data["variations-matrix"] = json_decode($configurableMatrixSerialized, true);
171+
unset($data["configurable-matrix-serialized"]);
172+
}
173+
}
174+
if (isset($data["associated_product_ids_serialized"])) {
175+
$associatedProductIdsSerialized = $data["associated_product_ids_serialized"];
176+
if ($associatedProductIdsSerialized != null && !empty($associatedProductIdsSerialized)) {
177+
$data["associated_product_ids"] = json_decode($associatedProductIdsSerialized, true);
178+
unset($data["associated_product_ids_serialized"]);
179+
}
180+
}
181+
return $data;
182+
}
183+
160184
/**
161185
* Notify customer when image was not deleted in specific case.
162186
* TODO: temporary workaround must be eliminated in MAGETWO-45306

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ public function afterInitialize(
5555
$this->productType->setUsedProductAttributeIds($attributes, $product);
5656

5757
$product->setNewVariationsAttributeSetId($setId);
58-
$associatedProductIds = $this->request->getPost('associated_product_ids', []);
59-
$variationsMatrix = $this->request->getParam('variations-matrix', []);
58+
$associatedProductIds = $this->request->getPost('associated_product_ids_serialized', '[]');
59+
if ($associatedProductIds !== null && !empty($associatedProductIds)) {
60+
$associatedProductIds = json_decode($associatedProductIds, true);
61+
}
62+
$variationsMatrix = $this->request->getParam('configurable-matrix-serialized', '[]');
63+
if ($variationsMatrix !== null && !empty($variationsMatrix)) {
64+
$variationsMatrix = json_decode($variationsMatrix, true);
65+
}
6066
if (!empty($variationsMatrix)) {
6167
$generatedProductIds = $this->variationHandler->generateSimpleProducts($product, $variationsMatrix);
6268
$associatedProductIds = array_merge($associatedProductIds, $generatedProductIds);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public function afterInitialize(
4747
\Magento\Catalog\Model\Product $configurableProduct
4848
) {
4949
$configurations = $this->request->getParam('configurations', []);
50+
if ($this->request->getParam('configurations_serialized')) {
51+
$configurations = json_decode($this->request->getParam('configurations_serialized'), true);
52+
}
5053
$configurations = $this->variationHandler->duplicateImagesForVariations($configurations);
5154
foreach ($configurations as $productId => $productData) {
5255
/** @var \Magento\Catalog\Model\Product $product */

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,23 @@ public function testAfterInitializeIfAttributesNotEmptyAndActionNameNotGenerateV
7979
{
8080
$this->productMock->expects($this->once())->method('getTypeId')->willReturn(ConfigurableProduct::TYPE_CODE);
8181
$associatedProductIds = ['key' => 'value'];
82+
$associatedProductIdsSerialized = json_encode($associatedProductIds);
8283
$generatedProductIds = ['key_one' => 'value_one'];
8384
$expectedArray = ['key' => 'value', 'key_one' => 'value_one'];
8485
$attributes = ['key' => 'value'];
8586
$postValue = 'postValue';
87+
$variationsMatrix = ['variationKey' => 'variationValue'];
88+
$variationsMatrixSerialized = json_encode($variationsMatrix);
89+
8690
$postValueMap = [
8791
['new-variations-attribute-set-id', null, $postValue],
88-
['associated_product_ids', [], $associatedProductIds],
92+
['associated_product_ids_serialized', '[]', $associatedProductIdsSerialized],
8993
['affect_configurable_product_attributes', null, $postValue],
9094
];
9195
$this->requestMock->expects($this->any())->method('getPost')->will($this->returnValueMap($postValueMap));
9296

9397
$paramValueMap = [
94-
['variations-matrix', [], $postValue],
98+
['configurable-matrix-serialized', '[]', $variationsMatrixSerialized],
9599
['attributes', null, $attributes],
96100
];
97101
$this->requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap($paramValueMap));
@@ -110,7 +114,7 @@ public function testAfterInitializeIfAttributesNotEmptyAndActionNameNotGenerateV
110114
'generateSimpleProducts'
111115
)->with(
112116
$this->productMock,
113-
$postValue
117+
$variationsMatrix
114118
)->will(
115119
$this->returnValue($generatedProductIds)
116120
);
@@ -123,16 +127,17 @@ public function testAfterInitializeIfAttributesNotEmptyAndActionNameGenerateVari
123127
{
124128
$this->productMock->expects($this->once())->method('getTypeId')->willReturn(ConfigurableProduct::TYPE_CODE);
125129
$associatedProductIds = ['key' => 'value'];
130+
$associatedProductIdsSerialized = json_encode($associatedProductIds);
126131
$attributes = ['key' => 'value'];
127132
$postValue = 'postValue';
128133
$valueMap = [
129134
['new-variations-attribute-set-id', null, $postValue],
130-
['associated_product_ids', [], $associatedProductIds],
135+
['associated_product_ids_serialized', '[]', $associatedProductIdsSerialized],
131136
['affect_configurable_product_attributes', null, $postValue],
132137
];
133138
$this->requestMock->expects($this->any())->method('getPost')->will($this->returnValueMap($valueMap));
134139
$paramValueMap = [
135-
['variations-matrix', [], []],
140+
['variations-matrix', '[]', '[]'],
136141
['attributes', null, $attributes],
137142
];
138143
$this->requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap($paramValueMap));

app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/attribute/steps/summary.phtml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,33 @@
1313

1414
<div class="admin__data-grid-wrap admin__data-grid-wrap-static">
1515
<!-- ko if: gridNew().length -->
16-
<!-- ko template: {name: getGridTemplate(), data: {
17-
grid: gridNew,
18-
id: getGridId(),
19-
title: $t('New Product Review'),
20-
note: $t('Here are the products you\'re about to create.')
21-
}} --><!-- /ko -->
16+
<!-- ko template: {name: getGridTemplate(), data: {
17+
grid: gridNew,
18+
paging: pagingNew,
19+
id: getGridId(),
20+
title: $t('New Product Review'),
21+
note: $t('Here are the products you\'re about to create.')
22+
}} --><!-- /ko -->
2223
<!-- /ko -->
2324

2425
<!-- ko if: gridExisting().length -->
25-
<!-- ko template: {name: getGridTemplate(), data: {
26-
grid: gridExisting,
27-
id: getGridId(),
28-
title: $t('Associated Products'),
29-
note: $t('You created these products for this configuration.')
30-
}} --><!-- /ko -->
26+
<!-- ko template: {name: getGridTemplate(), data: {
27+
paging: pagingExisting,
28+
grid: gridExisting,
29+
id: getGridId(),
30+
title: $t('Associated Products'),
31+
note: $t('You created these products for this configuration.')
32+
}} --><!-- /ko -->
3133
<!-- /ko -->
3234

3335
<!-- ko if: gridDeleted().length -->
34-
<!-- ko template: {name: getGridTemplate(), data: {
35-
grid: gridDeleted,
36-
id: getGridId(),
37-
title: $t('Disassociated Products'),
38-
note: $t('These products are not associated.')
39-
}} --><!-- /ko -->
36+
<!-- ko template: {name: getGridTemplate(), data: {
37+
paging: pagingDeleted,
38+
grid: gridDeleted,
39+
id: getGridId(),
40+
title: $t('Disassociated Products'),
41+
note: $t('These products are not associated.')
42+
}} --><!-- /ko -->
4043
<!-- /ko -->
4144
</div>
4245
</div>

app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ $currencySymbol = $block->getCurrencySymbol();
4242
</div>
4343
<!-- /ko -->
4444
</div>
45+
<div class="admin__data-grid-header">
46+
<div class="admin__data-grid-header-row row row-gutter">
47+
<div class="col-xs-12">
48+
<!-- ko template: { name: "ui/grid/paging/paging", data: paging } --><!-- /ko -->
49+
</div>
50+
</div>
51+
</div>
4552
<div class="admin__data-grid-wrap admin__data-grid-wrap-static">
4653
<table class="data-grid">
4754
<thead>
@@ -76,12 +83,12 @@ $currencySymbol = $block->getCurrencySymbol();
7683
</thead>
7784
<tbody data-bind="foreach: {data: productMatrix, as: 'variation'}">
7885
<tr data-role="row" data-bind="css: { _disabled: !variation.status, even: $index() % 2 },
79-
attr: { 'data-row-number': $index() }">
86+
attr: { 'data-row-number': variation.variationKey }">
8087
<td class="col-image" data-column="image">
8188
<div class="actions split actions-image-uploader">
8289
<div class="action-upload action split" data-action="upload-image">
8390
<!-- ko if: $parent.isShowPreviewImage(variation) -->
84-
<img data-bind='attr: {src: variation.images.preview}' class="variation"
91+
<img data-bind='attr: {src: $parent.getVariationImage(variation)}' class="variation"
8592
data-role="image"/>
8693
<!-- /ko -->
8794
<!-- ko if: variation.editable-->
@@ -119,27 +126,39 @@ $currencySymbol = $block->getCurrencySymbol();
119126
<!-- /ko -->
120127
<!-- ko if: variation.editable -->
121128
<input type="text" class="required-entry" data-bind="
122-
attr: {id: $parent.getRowId(variation, 'name'),
123-
name: $parent.getVariationRowName(variation, 'name'),
124-
value: variation.sku}"/>
129+
attr: {
130+
id: $parent.getRowId(variation, 'name'),
131+
name: $parent.getVariationRowName(variation, 'name')
132+
},
133+
value: variation.name
134+
"/>
125135
<input type="hidden" data-bind="
126-
attr: {id: $parent.getRowId(variation, 'configurable_attribute'),
127-
name: $parent.getVariationRowName(variation, 'configurable_attribute'),
128-
value: variation.attribute}"/>
136+
attr: {
137+
id: $parent.getRowId(variation, 'configurable_attribute'),
138+
name: $parent.getVariationRowName(variation, 'configurable_attribute')
139+
},
140+
value: variation.attribute
141+
"/>
129142
<!-- /ko -->
130143
<input type="hidden" data-role="status" data-bind="
131-
attr: {name: $parent.getVariationRowName(variation, 'status'),
132-
value: variation.status}"/>
144+
attr: {
145+
name: $parent.getVariationRowName(variation, 'status')
146+
},
147+
value: variation.status
148+
"/>
133149
</td>
134150
<td class="col-sku" data-column="sku">
135151
<!-- ko ifnot: variation.editable -->
136152
<!-- ko text: variation.sku --><!--/ko-->
137153
<!-- /ko -->
138154
<!-- ko if: variation.editable -->
139-
<input type="text" class="required-entry"
140-
data-bind="attr: {id: $parent.getRowId(variation, 'sku'),
141-
name: $parent.getVariationRowName(variation, 'sku'),
142-
value: variation.sku}"/>
155+
<input type="text" class="required-entry" data-bind="
156+
attr: {
157+
id: $parent.getRowId(variation, 'sku'),
158+
name: $parent.getVariationRowName(variation, 'sku')
159+
},
160+
value: variation.sku
161+
"/>
143162
<!-- /ko -->
144163
</td>
145164
<td class="col-price" data-column="price">
@@ -148,12 +167,16 @@ $currencySymbol = $block->getCurrencySymbol();
148167
<!-- /ko -->
149168
<!-- ko if: variation.editable -->
150169
<div class="addon">
151-
<input type="text"
152-
id=""
153-
class="required-entry validate-zero-or-greater"
154-
data-bind="attr: {id: $parent.getRowId(variation, 'price'),
155-
name: $parent.getVariationRowName(variation, 'price'),
156-
value: variation.price}"/>
170+
<input type="text" id="" class="required-entry validate-zero-or-greater" data-bind="
171+
attr: {
172+
id: $parent.getRowId(variation, 'price'),
173+
name: $parent.getVariationRowName(variation, 'price')
174+
},
175+
value: variation.price,
176+
event: {
177+
keyup: validatePrice()
178+
}
179+
"/>
157180
<label class="addafter"
158181
data-bind="attr: {for: $parent.getRowId(variation, 'price')">
159182
<strong data-bind="text: $parent.getCurrencySymbol()"></strong>
@@ -166,23 +189,27 @@ $currencySymbol = $block->getCurrencySymbol();
166189
<!-- ko text: variation.quantity --><!--/ko-->
167190
<!-- /ko -->
168191
<!-- ko if: variation.editable -->
169-
<input type="text"
170-
class="validate-zero-or-greater"
171-
data-bind="attr: {id: $parent.getRowId(variation, 'qty'),
172-
name: $parent.getVariationRowName(variation, 'quantity_and_stock_status/qty'),
173-
value: variation.quantity}"/>
192+
<input type="text" class="validate-zero-or-greater" data-bind="
193+
attr: {
194+
id: $parent.getRowId(variation, 'qty'),
195+
name: $parent.getVariationRowName(variation, 'quantity_and_stock_status/qty')
196+
},
197+
value: variation.quantity
198+
"/>
174199
<!-- /ko -->
175200
</td>
176201
<td class="col-weight" data-column="weight">
177202
<!-- ko ifnot: variation.editable -->
178203
<!-- ko text: variation.weight --><!--/ko-->
179204
<!-- /ko -->
180205
<!-- ko if: variation.editable -->
181-
<input type="text" class="validate-zero-or-greater"
182-
data-bind="
183-
attr: {id: $parent.getRowId(variation, 'weight'),
184-
name: $parent.getVariationRowName(variation, 'weight'),
185-
value: variation.weight}"/>
206+
<input type="text" class="validate-zero-or-greater" data-bind="
207+
attr: {
208+
id: $parent.getRowId(variation, 'weight'),
209+
name: $parent.getVariationRowName(variation, 'weight')
210+
},
211+
value: variation.weight
212+
"/>
186213
<!-- /ko -->
187214
</td>
188215
<!-- ko foreach: variation.options -->
@@ -227,6 +254,9 @@ $currencySymbol = $block->getCurrencySymbol();
227254
</td>
228255
</tr>
229256
</tbody>
257+
<input type="hidden" name="configurable-matrix-serialized" data-bind="value: productMatrixSerialized"/>
258+
<input type="hidden" name="associated_product_ids_serialized" data-bind="value: associatedProductsSerialized"/>
259+
<input type="hidden" name="configurations_serialized" data-bind="value: configurationsSerialized"/>
230260
</table>
231261
</div>
232262
</div>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright © 2016 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'Magento_Ui/js/grid/paging/sizes'
7+
], function (Sizes) {
8+
'use strict';
9+
10+
return Sizes.extend({
11+
defaults: {
12+
excludedOptions: ['100', '200']
13+
},
14+
15+
/**
16+
* @override
17+
*/
18+
initialize: function () {
19+
this._super();
20+
21+
this.excludedOptions.forEach(function (excludedOption) {
22+
delete this.options[excludedOption];
23+
}, this);
24+
this.updateArray();
25+
26+
return this;
27+
}
28+
});
29+
});

0 commit comments

Comments
 (0)