Skip to content

Commit 174dc06

Browse files
[EngCom] Public Pull Requests - 2.2-develop
- merged latest code from mainline branch
2 parents d5fb610 + 2b1bf75 commit 174dc06

File tree

63 files changed

+2185
-195
lines changed

Some content is hidden

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

63 files changed

+2185
-195
lines changed

app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,23 @@ public function getProductAttributeValue($product, $attribute)
214214
return (string)$value == '' ? __('No') : $value;
215215
}
216216

217+
/**
218+
* Check if any of the products has a value set for the attribute.
219+
*
220+
* @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute
221+
* @return bool
222+
*/
223+
public function hasAttributeValueForProducts(\Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute) : bool
224+
{
225+
foreach ($this->getItems() as $item) {
226+
if ($item->hasData($attribute->getAttributeCode())) {
227+
return true;
228+
}
229+
}
230+
231+
return false;
232+
}
233+
217234
/**
218235
* Retrieve Print URL
219236
*

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -530,19 +530,6 @@ public function getStoreId()
530530
return $this->_storeManager->getStore()->getId();
531531
}
532532

533-
/**
534-
* Get collection instance
535-
*
536-
* @return object
537-
* @deprecated 101.1.0 because collections should be used directly via factory
538-
*/
539-
public function getResourceCollection()
540-
{
541-
$collection = parent::getResourceCollection();
542-
$collection->setStoreId($this->getStoreId());
543-
return $collection;
544-
}
545-
546533
/**
547534
* Get product url model
548535
*

app/code/Magento/Catalog/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@
859859
<argument name="customFilters" xsi:type="array">
860860
<item name="category_id" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductCategoryFilter</item>
861861
<item name="store" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductStoreFilter</item>
862+
<item name="store_id" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductStoreFilter</item>
862863
<item name="website_id" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductWebsiteFilter</item>
863864
</argument>
864865
</arguments>

app/code/Magento/Catalog/view/adminhtml/requirejs-config.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,18 @@ var config = {
1616
},
1717
deps: [
1818
'Magento_Catalog/catalog/product'
19-
]
19+
],
20+
config: {
21+
mixins: {
22+
'Magento_Catalog/js/components/use-parent-settings/select': {
23+
'Magento_Catalog/js/components/use-parent-settings/toggle-disabled-mixin': true
24+
},
25+
'Magento_Catalog/js/components/use-parent-settings/textarea': {
26+
'Magento_Catalog/js/components/use-parent-settings/toggle-disabled-mixin': true
27+
},
28+
'Magento_Catalog/js/components/use-parent-settings/single-checkbox': {
29+
'Magento_Catalog/js/components/use-parent-settings/toggle-disabled-mixin': true
30+
}
31+
}
32+
}
2033
};

app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,34 +459,34 @@
459459
</checkbox>
460460
</formElements>
461461
</field>
462-
<field name="custom_design" sortOrder="180" formElement="select">
462+
<field name="custom_design" component="Magento_Catalog/js/components/use-parent-settings/select" sortOrder="180" formElement="select">
463463
<settings>
464464
<dataType>string</dataType>
465465
<label translate="true">Theme</label>
466466
<imports>
467-
<link name="disabled">${ $.parentName }.custom_use_parent_settings:checked</link>
467+
<link name="serviceDisabled">${ $.parentName }.custom_use_parent_settings:checked</link>
468468
</imports>
469469
</settings>
470470
</field>
471-
<field name="page_layout" sortOrder="190" formElement="select">
471+
<field name="page_layout" component="Magento_Catalog/js/components/use-parent-settings/select" sortOrder="190" formElement="select">
472472
<settings>
473473
<dataType>string</dataType>
474474
<label translate="true">Layout</label>
475475
<imports>
476-
<link name="disabled">${ $.parentName }.custom_use_parent_settings:checked</link>
476+
<link name="serviceDisabled">${ $.parentName }.custom_use_parent_settings:checked</link>
477477
</imports>
478478
</settings>
479479
</field>
480-
<field name="custom_layout_update" sortOrder="200" formElement="textarea">
480+
<field name="custom_layout_update" component="Magento_Catalog/js/components/use-parent-settings/textarea" sortOrder="200" formElement="textarea">
481481
<settings>
482482
<dataType>string</dataType>
483483
<label translate="true">Layout Update XML</label>
484484
<imports>
485-
<link name="disabled">ns = ${ $.ns }, index = custom_use_parent_settings :checked</link>
485+
<link name="serviceDisabled">${ $.parentName }.custom_use_parent_settings:checked</link>
486486
</imports>
487487
</settings>
488488
</field>
489-
<field name="custom_apply_to_products" component="Magento_Ui/js/form/element/single-checkbox" sortOrder="210" formElement="checkbox">
489+
<field name="custom_apply_to_products" component="Magento_Catalog/js/components/use-parent-settings/single-checkbox" sortOrder="210" formElement="checkbox">
490490
<argument name="data" xsi:type="array">
491491
<item name="config" xsi:type="array">
492492
<item name="default" xsi:type="number">0</item>
@@ -499,7 +499,7 @@
499499
<dataType>boolean</dataType>
500500
<label translate="true">Apply Design to Products</label>
501501
<imports>
502-
<link name="disabled">ns = ${ $.ns }, index = custom_use_parent_settings:checked</link>
502+
<link name="serviceDisabled">${ $.parentName }.custom_use_parent_settings:checked</link>
503503
</imports>
504504
</settings>
505505
<formElements>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/**
7+
* @api
8+
*/
9+
define([
10+
'Magento_Ui/js/form/element/select'
11+
], function (Component) {
12+
'use strict';
13+
14+
return Component;
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/**
7+
* @api
8+
*/
9+
define([
10+
'Magento_Ui/js/form/element/single-checkbox'
11+
], function (Component) {
12+
'use strict';
13+
14+
return Component;
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/**
7+
* @api
8+
*/
9+
define([
10+
'Magento_Ui/js/form/element/textarea'
11+
], function (Component) {
12+
'use strict';
13+
14+
return Component;
15+
});
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'underscore'
8+
], function (_) {
9+
'use strict';
10+
11+
var mixin = {
12+
defaults: {
13+
imports: {
14+
toggleDisabled: '${ $.parentName }.custom_use_parent_settings:checked'
15+
},
16+
useParent: false,
17+
useDefaults: false
18+
},
19+
20+
/**
21+
* Disable form input if settings for parent section is used
22+
* or default value is applied.
23+
*
24+
* @param {Boolean} isUseParent
25+
*/
26+
toggleDisabled: function (isUseParent) {
27+
var disabled = this.useParent = isUseParent;
28+
29+
if (!disabled && !_.isUndefined(this.service)) {
30+
disabled = !!this.isUseDefault();
31+
}
32+
33+
this.saveUseDefaults();
34+
this.disabled(disabled);
35+
},
36+
37+
/**
38+
* Stores original state of the field.
39+
*/
40+
saveUseDefaults: function () {
41+
this.useDefaults = this.disabled();
42+
},
43+
44+
/** @inheritdoc */
45+
setInitialValue: function () {
46+
this._super();
47+
this.isUseDefault(this.useDefaults);
48+
49+
return this;
50+
},
51+
52+
/** @inheritdoc */
53+
toggleUseDefault: function (state) {
54+
this._super();
55+
this.disabled(state || this.useParent);
56+
}
57+
};
58+
59+
return function (target) {
60+
return target.extend(mixin);
61+
};
62+
});

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

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
/* @var $block \Magento\Catalog\Block\Product\Compare\ListCompare */
1010
?>
11-
<?php $_total = $block->getItems()->getSize() ?>
12-
<?php if ($_total): ?>
11+
<?php $total = $block->getItems()->getSize() ?>
12+
<?php if ($total): ?>
1313
<a href="#" class="action print hidden-print" title="<?= /* @escapeNotVerified */ __('Print This Page') ?>">
1414
<span><?= /* @escapeNotVerified */ __('Print This Page') ?></span>
1515
</a>
@@ -24,14 +24,14 @@
2424
<caption class="table-caption"><?= /* @escapeNotVerified */ __('Compare Products') ?></caption>
2525
<thead>
2626
<tr>
27-
<?php $_i = 0 ?>
28-
<?php foreach ($block->getItems() as $_item): ?>
29-
<?php if ($_i++ == 0): ?>
27+
<?php $index = 0 ?>
28+
<?php foreach ($block->getItems() as $item): ?>
29+
<?php if ($index++ == 0): ?>
3030
<th scope="row" class="cell label remove"><span><?= /* @escapeNotVerified */ __('Remove Product') ?></span></th>
3131
<?php endif; ?>
3232
<td class="cell remove product hidden-print">
33-
<?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');?>
34-
<a href="#" data-post='<?= /* @escapeNotVerified */ $compareHelper->getPostDataRemove($_item) ?>'
33+
<?php $compareHelper = $this->helper(\Magento\Catalog\Helper\Product\Compare::class);?>
34+
<a href="#" data-post='<?= /* @escapeNotVerified */ $compareHelper->getPostDataRemove($item) ?>'
3535
class="action delete" title="<?= /* @escapeNotVerified */ __('Remove Product') ?>">
3636
<span><?= /* @escapeNotVerified */ __('Remove Product') ?></span>
3737
</a>
@@ -41,44 +41,44 @@
4141
</thead>
4242
<tbody>
4343
<tr>
44-
<?php $_i = 0; ?>
45-
<?php $_helper = $this->helper('Magento\Catalog\Helper\Output'); ?>
46-
<?php /** @var $_item \Magento\Catalog\Model\Product */ ?>
47-
<?php foreach ($block->getItems() as $_item): ?>
48-
<?php if ($_i++ == 0): ?>
44+
<?php $index = 0; ?>
45+
<?php $helper = $this->helper(\Magento\Catalog\Helper\Output::class); ?>
46+
<?php /** @var $item \Magento\Catalog\Model\Product */ ?>
47+
<?php foreach ($block->getItems() as $item): ?>
48+
<?php if ($index++ == 0): ?>
4949
<th scope="row" class="cell label product"><span><?= /* @escapeNotVerified */ __('Product') ?></span></th>
5050
<?php endif; ?>
5151
<td data-th="<?= $block->escapeHtml(__('Product')) ?>" class="cell product info">
52-
<a class="product-item-photo" href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" title="<?= /* @escapeNotVerified */ $block->stripTags($_item->getName(), null, true) ?>">
53-
<?= $block->getImage($_item, 'product_comparison_list')->toHtml() ?>
52+
<a class="product-item-photo" href="<?= /* @escapeNotVerified */ $block->getProductUrl($item) ?>" title="<?= /* @escapeNotVerified */ $block->stripTags($item->getName(), null, true) ?>">
53+
<?= $block->getImage($item, 'product_comparison_list')->toHtml() ?>
5454
</a>
5555
<strong class="product-item-name">
56-
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" title="<?= /* @escapeNotVerified */ $block->stripTags($_item->getName(), null, true) ?>">
57-
<?= /* @escapeNotVerified */ $_helper->productAttribute($_item, $_item->getName(), 'name') ?>
56+
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($item) ?>" title="<?= /* @escapeNotVerified */ $block->stripTags($item->getName(), null, true) ?>">
57+
<?= /* @escapeNotVerified */ $helper->productAttribute($item, $item->getName(), 'name') ?>
5858
</a>
5959
</strong>
60-
<?= $block->getReviewsSummaryHtml($_item, 'short') ?>
61-
<?= /* @escapeNotVerified */ $block->getProductPrice($_item, '-compare-list-top') ?>
60+
<?= $block->getReviewsSummaryHtml($item, 'short') ?>
61+
<?= /* @escapeNotVerified */ $block->getProductPrice($item, '-compare-list-top') ?>
6262
<div class="product-item-actions hidden-print">
6363
<div class="actions-primary">
64-
<?php if ($_item->isSaleable()): ?>
65-
<form data-role="tocart-form" action="<?= /* @escapeNotVerified */ $this->helper('Magento\Catalog\Helper\Product\Compare')->getAddToCartUrl($_item) ?>" method="post">
64+
<?php if ($item->isSaleable()): ?>
65+
<form data-role="tocart-form" action="<?= /* @escapeNotVerified */ $this->helper(\Magento\Catalog\Helper\Product\Compare::class)->getAddToCartUrl($item) ?>" method="post">
6666
<?= $block->getBlockHtml('formkey') ?>
6767
<button type="submit" class="action tocart primary">
6868
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
6969
</button>
7070
</form>
7171
<?php else: ?>
72-
<?php if ($_item->getIsSalable()): ?>
72+
<?php if ($item->getIsSalable()): ?>
7373
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
7474
<?php else: ?>
7575
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
7676
<?php endif; ?>
7777
<?php endif; ?>
7878
</div>
79-
<?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()) : ?>
79+
<?php if ($this->helper(\Magento\Wishlist\Helper\Data::class)->isAllow()) : ?>
8080
<div class="secondary-addto-links actions-secondary" data-role="add-to-links">
81-
<a href="#" data-post='<?= /* @escapeNotVerified */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist">
81+
<a href="#" data-post='<?= /* @escapeNotVerified */ $block->getAddToWishlistParams($item) ?>' class="action towishlist" data-action="add-to-wishlist">
8282
<span><?= /* @escapeNotVerified */ __('Add to Wish List') ?></span>
8383
</a>
8484
</div>
@@ -89,39 +89,41 @@
8989
</tr>
9090
</tbody>
9191
<tbody>
92-
<?php foreach ($block->getAttributes() as $_attribute): ?>
93-
<tr>
94-
<?php $_i = 0 ?>
95-
<?php foreach ($block->getItems() as $_item): ?>
96-
<?php if ($_i++ == 0): ?>
97-
<th scope="row" class="cell label">
98-
<span class="attribute label">
99-
<?= $block->escapeHtml($_attribute->getStoreLabel() ? $_attribute->getStoreLabel() : __($_attribute->getFrontendLabel())) ?>
100-
</span>
101-
</th>
102-
<?php endif; ?>
103-
<td class="cell product attribute">
104-
<div class="attribute value">
105-
<?php switch ($_attribute->getAttributeCode()) {
106-
case "price": ?>
107-
<?php
108-
/* @escapeNotVerified */ echo $block->getProductPrice(
109-
$_item,
110-
'-compare-list-' . $_attribute->getCode()
111-
)
112-
?>
113-
<?php break;
114-
case "small_image": ?>
115-
<?php $block->getImage($_item, 'product_small_image')->toHtml(); ?>
92+
<?php foreach ($block->getAttributes() as $attribute): ?>
93+
<?php $index = 0; ?>
94+
<?php if ($block->hasAttributeValueForProducts($attribute)): ?>
95+
<tr>
96+
<?php foreach ($block->getItems() as $item): ?>
97+
<?php if ($index++ == 0): ?>
98+
<th scope="row" class="cell label">
99+
<span class="attribute label">
100+
<?= $block->escapeHtml($attribute->getStoreLabel() ? $attribute->getStoreLabel() : __($attribute->getFrontendLabel())) ?>
101+
</span>
102+
</th>
103+
<?php endif; ?>
104+
<td class="cell product attribute">
105+
<div class="attribute value">
106+
<?php switch ($attribute->getAttributeCode()) {
107+
case "price": ?>
108+
<?php
109+
/* @escapeNotVerified */ echo $block->getProductPrice(
110+
$item,
111+
'-compare-list-' . $attribute->getCode()
112+
)
113+
?>
114+
<?php break;
115+
case "small_image": ?>
116+
<?php $block->getImage($item, 'product_small_image')->toHtml(); ?>
117+
<?php break;
118+
default: ?>
119+
<?= /* @escapeNotVerified */ $helper->productAttribute($item, $block->getProductAttributeValue($item, $attribute), $attribute->getAttributeCode()) ?>
116120
<?php break;
117-
default: ?>
118-
<?= /* @escapeNotVerified */ $_helper->productAttribute($_item, $block->getProductAttributeValue($_item, $_attribute), $_attribute->getAttributeCode()) ?>
119-
<?php break;
120-
} ?>
121-
</div>
122-
</td>
123-
<?php endforeach; ?>
124-
</tr>
121+
} ?>
122+
</div>
123+
</td>
124+
<?php endforeach; ?>
125+
</tr>
126+
<?php endif; ?>
125127
<?php endforeach; ?>
126128
</tbody>
127129
</table>

0 commit comments

Comments
 (0)