Skip to content

Commit cb2d5c0

Browse files
[EngCom] Public Pull Requests - 2.2-develop
- merged latest code from mainline branch
2 parents d1c1d77 + ef55fa7 commit cb2d5c0

File tree

13 files changed

+222
-23
lines changed

13 files changed

+222
-23
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ protected function doAddWebsiteNamesToResult()
818818
foreach ($this as $product) {
819819
if (isset($productWebsites[$product->getId()])) {
820820
$product->setData('websites', $productWebsites[$product->getId()]);
821+
$product->setData('website_ids', $productWebsites[$product->getId()]);
821822
}
822823
}
823824
return $this;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Observer;
9+
10+
use Magento\Catalog\Model\Indexer\Category\Product\Processor;
11+
use Magento\Framework\Event\Observer;
12+
use Magento\Framework\Event\ObserverInterface;
13+
14+
/**
15+
* Checks if a category has changed products and depends on indexer configuration
16+
* marks `Category Products` indexer as invalid or reindexes affected products.
17+
*/
18+
class CategoryProductIndexer implements ObserverInterface
19+
{
20+
/**
21+
* @var Processor
22+
*/
23+
private $processor;
24+
25+
/**
26+
* @param Processor $processor
27+
*/
28+
public function __construct(Processor $processor)
29+
{
30+
$this->processor = $processor;
31+
}
32+
33+
/**
34+
* @inheritdoc
35+
*/
36+
public function execute(Observer $observer)
37+
{
38+
$productIds = $observer->getEvent()->getProductIds();
39+
if (!empty($productIds) && $this->processor->isIndexerScheduled()) {
40+
$this->processor->markIndexerAsInvalid();
41+
}
42+
}
43+
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@ private function canDisplayUseDefault(ProductAttributeInterface $attribute)
909909
$attributeCode = $attribute->getAttributeCode();
910910
/** @var Product $product */
911911
$product = $this->locator->getProduct();
912+
if ($product->isLockedAttribute($attributeCode)) {
913+
return false;
914+
}
912915

913916
if (isset($this->canDisplayUseDefault[$attributeCode])) {
914917
return $this->canDisplayUseDefault[$attributeCode];

app/code/Magento/Catalog/etc/adminhtml/events.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
<event name="cms_wysiwyg_images_static_urls_allowed">
1010
<observer name="catalog_wysiwyg" instance="Magento\Catalog\Observer\CatalogCheckIsUsingStaticUrlsAllowedObserver" />
1111
</event>
12+
<event name="catalog_category_change_products">
13+
<observer name="category_product_indexer" instance="Magento\Catalog\Observer\CategoryProductIndexer"/>
14+
</event>
1215
</config>

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
define([
77
'jquery',
88
'mage/translate',
9+
'underscore',
10+
'Magento_Catalog/js/product/view/product-ids-resolver',
911
'jquery/ui'
10-
], function ($, $t) {
12+
], function ($, $t, _, idsResolver) {
1113
'use strict';
1214

1315
$.widget('mage.catalogAddToCart', {
@@ -75,17 +77,18 @@ define([
7577
/**
7678
* Handler for the form 'submit' event
7779
*
78-
* @param {Object} form
80+
* @param {jQuery} form
7981
*/
8082
submitForm: function (form) {
8183
this.ajaxSubmit(form);
8284
},
8385

8486
/**
85-
* @param {String} form
87+
* @param {jQuery} form
8688
*/
8789
ajaxSubmit: function (form) {
8890
var self = this,
91+
productIds = idsResolver(form),
8992
formData = new FormData(form[0]);
9093

9194
$(self.options.minicartSelector).trigger('contentLoading');
@@ -113,6 +116,7 @@ define([
113116

114117
$(document).trigger('ajax:addToCart', {
115118
'sku': form.data().productSku,
119+
'productIds': productIds,
116120
'form': form,
117121
'response': res
118122
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'underscore',
7+
'Magento_Catalog/js/product/view/product-ids'
8+
], function (_, productIds) {
9+
'use strict';
10+
11+
/**
12+
* Returns id's of products in form.
13+
*
14+
* @param {jQuery} $form
15+
* @return {Array}
16+
*/
17+
return function ($form) {
18+
var idSet = productIds(),
19+
product = _.findWhere($form.serializeArray(), {
20+
name: 'product'
21+
});
22+
23+
if (!_.isUndefined(product)) {
24+
idSet.push(product.value);
25+
}
26+
27+
return _.uniq(idSet);
28+
};
29+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'ko'
8+
], function (ko) {
9+
'use strict';
10+
11+
return ko.observableArray([]);
12+
});

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ define([
226226
var productData = this._getProductById(Number(elem.data('cart-item')));
227227

228228
if (!_.isUndefined(productData)) {
229-
$(document).trigger('ajax:updateCartItemQty', productData['product_sku']);
229+
$(document).trigger('ajax:updateCartItemQty');
230230
}
231231
this._hideItemButton(elem);
232232
},
@@ -253,7 +253,9 @@ define([
253253
var productData = this._getProductById(Number(elem.data('cart-item')));
254254

255255
if (!_.isUndefined(productData)) {
256-
$(document).trigger('ajax:removeFromCart', productData['product_sku']);
256+
$(document).trigger('ajax:removeFromCart', {
257+
productIds: [productData['product_id']]
258+
});
257259
}
258260
},
259261

app/code/Magento/GroupedProduct/view/frontend/templates/product/view/type/grouped.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
2020

2121
<div class="table-wrapper grouped">
22-
<table class="table data grouped" id="super-product-table">
22+
<table class="table data grouped"
23+
id="super-product-table"
24+
data-mage-init='{ "Magento_GroupedProduct/js/product-ids-resolver": {} }'>
2325
<caption class="table-caption"><?= /* @escapeNotVerified */ __('Grouped product items') ?></caption>
2426
<thead>
2527
<tr>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'jquery',
7+
'Magento_Catalog/js/product/view/product-ids'
8+
], function ($, productIds) {
9+
'use strict';
10+
11+
/**
12+
* Returns id's of products in form.
13+
*
14+
* @param {Object} config
15+
* @param {HTMLElement} element
16+
* @return {Array}
17+
*/
18+
return function (config, element) {
19+
$(element).find('div[data-product-id]').each(function () {
20+
productIds.push($(this).data('productId').toString());
21+
});
22+
23+
return productIds();
24+
};
25+
});

0 commit comments

Comments
 (0)