Skip to content

Commit 1231495

Browse files
author
Magento CICD
authored
merge magento/2.1-develop into magento-engcom/2.1-develop-prs
2 parents 6a51338 + fdf7480 commit 1231495

File tree

27 files changed

+1094
-171
lines changed

27 files changed

+1094
-171
lines changed

app/code/Magento/Catalog/Block/Product/View/Gallery.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public function getGalleryImagesJson()
117117
'caption' => $image->getLabel(),
118118
'position' => $image->getPosition(),
119119
'isMain' => $this->isMainImage($image),
120+
'type' => str_replace('external-', '', $image->getMediaType()),
121+
'videoUrl' => $image->getVideoUrl(),
120122
];
121123
}
122124
if (empty($imagesItems)) {
@@ -127,6 +129,8 @@ public function getGalleryImagesJson()
127129
'caption' => '',
128130
'position' => '0',
129131
'isMain' => true,
132+
'type' => 'image',
133+
'videoUrl' => null,
130134
];
131135
}
132136
return json_encode($imagesItems);

app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
// @codingStandardsIgnoreFile
8+
69
?>
710
<?php
811
/** @var \Magento\Catalog\Pricing\Render\FinalPriceBox $block */
@@ -14,11 +17,14 @@ $priceLabel = ($block->getPriceLabel() !== null)
1417
: '';
1518
?>
1619
<p class="price-as-configured">
17-
<?php /* @escapeNotVerified */ echo $block->renderAmount($configuredPrice->getAmount(), [
18-
'display_label' => $priceLabel,
19-
'price_id' => $block->getPriceId('product-price-'),
20-
'price_type' => 'finalPrice',
21-
'include_container' => true,
22-
'schema' => $schema
23-
]); ?>
20+
<?php if ($configuredPrice->getAmount()->getValue() !== null): ?>
21+
<?php /* @noEscape */
22+
echo $block->renderAmount($configuredPrice->getAmount(), [
23+
'display_label' => $priceLabel,
24+
'price_id' => $block->getPriceId('product-price-'),
25+
'price_type' => 'finalPrice',
26+
'include_container' => true,
27+
'schema' => $schema
28+
]); ?>
29+
<?php endif; ?>
2430
</p>

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
7878
<div class="actions-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
7979
<?php if ($_product->isSaleable()): ?>
8080
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
81-
<form data-role="tocart-form" action="<?php /* @escapeNotVerified */ echo $postParams['action']; ?>" method="post">
81+
<form data-role="tocart-form" data-product-sku="<?php echo $block->escapeHtml($_product->getSku()); ?>"
82+
action="<?php echo $block->escapeHtml($postParams['action']); ?>" method="post">
8283
<input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $postParams['data']['product']; ?>">
8384
<input type="hidden" name="<?php /* @escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* @escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
8485
<?php echo $block->getBlockHtml('formkey')?>
@@ -121,7 +122,9 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
121122
<script type="text/x-magento-init">
122123
{
123124
"[data-role=tocart-form], .form.map.checkout": {
124-
"catalogAddToCart": {}
125+
"catalogAddToCart": {
126+
"product_sku": "<?php /* @escapeNotVerified */ echo $_product->getSku() ?>"
127+
}
125128
}
126129
}
127130
</script>

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
</div>
4141
</div>
4242
<?php endif; ?>
43-
<script type="text/x-magento-init">
43+
<?php if ($block->isRedirectToCartEnabled()) : ?>
44+
<script type="text/x-magento-init">
4445
{
4546
"#product_addtocart_form": {
4647
"Magento_Catalog/product/view/validation": {
@@ -49,13 +50,11 @@
4950
}
5051
}
5152
</script>
52-
<?php if (!$block->isRedirectToCartEnabled()) : ?>
53-
<script type="text/x-magento-init">
53+
<?php else : ?>
54+
<script type="text/x-magento-init">
5455
{
5556
"#product_addtocart_form": {
56-
"catalogAddToCart": {
57-
"bindSubmit": false
58-
}
57+
"Magento_Catalog/js/validate-product": {}
5958
}
6059
}
6160
</script>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<?php $_product = $block->getProduct(); ?>
1717

1818
<div class="product-add-form">
19-
<form action="<?php /* @escapeNotVerified */ echo $block->getSubmitUrl($_product) ?>" method="post"
19+
<form data-product-sku="<?php echo $block->escapeHtml($_product->getSku()) ?>"
20+
action="<?php echo $block->escapeHtml($block->getSubmitUrl($_product)) ?>" method="post"
2021
id="product_addtocart_form"<?php if ($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
2122
<input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $_product->getId() ?>" />
2223
<input type="hidden" name="selected_configurable_option" value="" />

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ define([
7979
}
8080
},
8181
success: function(res) {
82+
$(document).trigger('ajax:addToCart', form.data().productSku);
83+
8284
if (self.isLoaderEnabled()) {
8385
$('body').trigger(self.options.processStop);
8486
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright © 2013-2017 Magento, Inc. 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/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,28 +300,40 @@ public function getProductAttributes($storeId, array $productIds, array $attribu
300300
foreach ($attributeTypes as $backendType => $attributeIds) {
301301
if ($attributeIds) {
302302
$tableName = $this->getTable('catalog_product_entity_' . $backendType);
303-
$selects[] = $this->connection->select()->from(
304-
['t_default' => $tableName],
305-
[$linkField, 'attribute_id']
303+
304+
$select = $this->connection->select()->from(
305+
['t' => $tableName],
306+
[
307+
$linkField => 't.' . $linkField,
308+
'attribute_id' => 't.attribute_id',
309+
'value' => $this->unifyField($ifStoreValue, $backendType),
310+
]
306311
)->joinLeft(
307312
['t_store' => $tableName],
308313
$this->connection->quoteInto(
309-
't_default.' . $linkField . '=t_store.' . $linkField .
310-
' AND t_default.attribute_id=t_store.attribute_id' .
314+
't.' . $linkField . '=t_store.' . $linkField .
315+
' AND t.attribute_id=t_store.attribute_id' .
311316
' AND t_store.store_id = ?',
312317
$storeId
313318
),
314-
['value' => $this->unifyField($ifStoreValue, $backendType)]
315-
)->where(
316-
't_default.store_id = ?',
317-
0
319+
[]
320+
)->joinLeft(
321+
['t_default' => $tableName],
322+
$this->connection->quoteInto(
323+
't.' . $linkField . '=t_default.' . $linkField .
324+
' AND t.attribute_id=t_default.attribute_id' .
325+
' AND t_default.store_id = ?',
326+
0
327+
),
328+
[]
318329
)->where(
319-
't_default.attribute_id IN (?)',
330+
't.attribute_id IN (?)',
320331
$attributeIds
321332
)->where(
322-
't_default.' . $linkField . ' IN (?)',
333+
't.' . $linkField . ' IN (?)',
323334
array_keys($productLinkFieldsToEntityIdMap)
324-
);
335+
)->distinct();
336+
$selects[] = $select;
325337
}
326338
}
327339

app/code/Magento/Checkout/view/frontend/web/js/sidebar.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ define([
177177

178178
_removeItem: function (elem) {
179179
var itemId = elem.data('cart-item');
180+
180181
this._ajax(this.options.url.remove, {
181182
item_id: itemId
182183
}, elem, this._removeItemAfter);
@@ -185,11 +186,15 @@ define([
185186
/**
186187
* Update content after item remove
187188
*
188-
* @param elem
189-
* @param response
189+
* @param {Object} elem
190190
* @private
191191
*/
192-
_removeItemAfter: function (elem, response) {
192+
_removeItemAfter: function (elem) {
193+
var productData = customerData.get('cart')().items.find(function (item) {
194+
return Number(elem.data('cart-item')) === Number(item['item_id']);
195+
});
196+
197+
$(document).trigger('ajax:removeFromCart', productData['product_sku']);
193198
},
194199

195200
/**
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Block\Plugin\Product\Media;
7+
8+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
9+
use Magento\Catalog\Model\Product;
10+
11+
/**
12+
* Provides a serialized media gallery data for configurable product options.
13+
*/
14+
class Gallery
15+
{
16+
/**
17+
* @param \Magento\Catalog\Block\Product\View\Gallery $subject
18+
* @param string $result
19+
* @return string
20+
*/
21+
public function afterGetOptionsMediaGalleryDataJson(
22+
\Magento\Catalog\Block\Product\View\Gallery $subject,
23+
$result
24+
) {
25+
$result = json_decode($result, true);
26+
$parentProduct = $subject->getProduct();
27+
if ($parentProduct->getTypeId() == Configurable::TYPE_CODE) {
28+
/** @var Configurable $productType */
29+
$productType = $parentProduct->getTypeInstance();
30+
$products = $productType->getUsedProducts($parentProduct);
31+
/** @var Product $product */
32+
foreach ($products as $product) {
33+
$key = $product->getId();
34+
$result[$key] = $this->getProductGallery($product);
35+
}
36+
}
37+
return json_encode($result);
38+
}
39+
40+
/**
41+
* @param Product $product
42+
* @return array
43+
*/
44+
private function getProductGallery($product)
45+
{
46+
$result = [];
47+
$images = $product->getMediaGalleryImages();
48+
foreach ($images as $image) {
49+
$result[] = [
50+
'mediaType' => $image->getMediaType(),
51+
'videoUrl' => $image->getVideoUrl(),
52+
'isBase' => $product->getImage() == $image->getFile(),
53+
];
54+
}
55+
return $result;
56+
}
57+
}

0 commit comments

Comments
 (0)