Skip to content

Commit 3ac46f3

Browse files
author
cspruiell
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-52905-Group-Product
2 parents 93772a3 + 25b6600 commit 3ac46f3

File tree

68 files changed

+2144
-246
lines changed

Some content is hidden

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

68 files changed

+2144
-246
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/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@ public function __construct(
5656
public function build($productId)
5757
{
5858
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
59+
$productTable = $this->resource->getTableName('catalog_product_entity');
5960

6061
return [$this->resource->getConnection()->select()
61-
->from(['parent' => 'catalog_product_entity'], '')
62+
->from(['parent' => $productTable], '')
6263
->joinInner(
6364
['link' => $this->resource->getTableName('catalog_product_relation')],
6465
"link.parent_id = parent.$linkField",
6566
[]
6667
)->joinInner(
67-
['child' => 'catalog_product_entity'],
68+
['child' => $productTable],
6869
"child.entity_id = link.child_id",
6970
['entity_id']
7071
)->joinInner(

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByBasePrice.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ public function build($productId)
6565
{
6666
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
6767
$priceAttribute = $this->eavConfig->getAttribute(Product::ENTITY, 'price');
68+
$productTable = $this->resource->getTableName('catalog_product_entity');
69+
6870
$priceSelect = $this->resource->getConnection()->select()
69-
->from(['parent' => 'catalog_product_entity'], '')
71+
->from(['parent' => $productTable], '')
7072
->joinInner(
7173
['link' => $this->resource->getTableName('catalog_product_relation')],
7274
"link.parent_id = parent.$linkField",
7375
[]
7476
)->joinInner(
75-
['child' => 'catalog_product_entity'],
77+
['child' => $productTable],
7678
"child.entity_id = link.child_id",
7779
['entity_id']
7880
)->joinInner(

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderBySpecialPrice.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,16 @@ public function build($productId)
8686
$specialPriceToDate = $this->eavConfig->getAttribute(Product::ENTITY, 'special_to_date');
8787
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
8888
$currentDate = $this->dateTime->formatDate($timestamp, false);
89+
$productTable = $this->resource->getTableName('catalog_product_entity');
8990

9091
$specialPrice = $this->resource->getConnection()->select()
91-
->from(['parent' => 'catalog_product_entity'], '')
92+
->from(['parent' => $productTable], '')
9293
->joinInner(
9394
['link' => $this->resource->getTableName('catalog_product_relation')],
9495
"link.parent_id = parent.$linkField",
9596
[]
9697
)->joinInner(
97-
['child' => 'catalog_product_entity'],
98+
['child' => $productTable],
9899
"child.entity_id = link.child_id",
99100
['entity_id']
100101
)->joinInner(

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByTierPrice.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,16 @@ public function __construct(
6868
public function build($productId)
6969
{
7070
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
71+
$productTable = $this->resource->getTableName('catalog_product_entity');
72+
7173
$priceSelect = $this->resource->getConnection()->select()
72-
->from(['parent' => 'catalog_product_entity'], '')
74+
->from(['parent' => $productTable], '')
7375
->joinInner(
7476
['link' => $this->resource->getTableName('catalog_product_relation')],
7577
"link.parent_id = parent.$linkField",
7678
[]
7779
)->joinInner(
78-
['child' => 'catalog_product_entity'],
80+
['child' => $productTable],
7981
"child.entity_id = link.child_id",
8082
['entity_id']
8183
)->joinInner(

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/CatalogRule/Model/ResourceModel/Product/LinkedProductSelectBuilderByCatalogRulePrice.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,16 @@ public function build($productId)
7474
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
7575
$currentDate = $this->dateTime->formatDate($timestamp, false);
7676
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
77+
$productTable = $this->resource->getTableName('catalog_product_entity');
7778

7879
return [$this->resource->getConnection()->select()
79-
->from(['parent' => 'catalog_product_entity'], '')
80+
->from(['parent' => $productTable], '')
8081
->joinInner(
8182
['link' => $this->resource->getTableName('catalog_product_relation')],
8283
"link.parent_id = parent.$linkField",
8384
[]
8485
)->joinInner(
85-
['child' => 'catalog_product_entity'],
86+
['child' => $productTable],
8687
"child.entity_id = link.child_id",
8788
['entity_id']
8889
)->joinInner(

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);

0 commit comments

Comments
 (0)