Skip to content

Commit 0a8e77a

Browse files
Merge pull request #1339 from magento-engcom/develop-prs
[EngCom] Public Pull Requests - MAGETWO-70817: remove redundant else and use strict check #10271 - MAGETWO-70787: update phpserver to support versioned static urls #10250 - MAGETWO-70764: Fix overwrite default value image/file with NULL #10253 - MAGETWO-70761: Show values that are duplicate in attribute error msg #10213 - MAGETWO-70758: Fix for #4530 $product->getRatingSummary() always returns null […] #10248 - MAGETWO-70706: simplify product lists #2 #9019 - MAGETWO-70669: Fix fatal errors with deleteOptionsAndSelections #7711 - MAGETWO-70464: Fix shipping address can use for billing #10130 - MAGETWO-69913: magento/magento2 #9196 - Products ordered report doesn't show simple (child) products of configurable products #9908
2 parents 2e8d837 + 4b179ac commit 0a8e77a

File tree

27 files changed

+742
-711
lines changed

27 files changed

+742
-711
lines changed

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,13 @@ protected function _initAttributes()
648648
*/
649649
protected function deleteOptionsAndSelections($productIds)
650650
{
651+
if (empty($productIds)) {
652+
return $this;
653+
}
654+
651655
$optionTable = $this->_resource->getTableName('catalog_product_bundle_option');
652656
$optionValueTable = $this->_resource->getTableName('catalog_product_bundle_option_value');
657+
$selectionTable = $this->_resource->getTableName('catalog_product_bundle_selection');
653658
$valuesIds = $this->connection->fetchAssoc($this->connection->select()->from(
654659
['bov' => $optionValueTable],
655660
['value_id']
@@ -662,17 +667,16 @@ protected function deleteOptionsAndSelections($productIds)
662667
$productIds
663668
));
664669
$this->connection->delete(
665-
$optionTable,
670+
$optionValueTable,
666671
$this->connection->quoteInto('value_id IN (?)', array_keys($valuesIds))
667672
);
668-
$productIdsInWhere = $this->connection->quoteInto('parent_id IN (?)', $productIds);
669673
$this->connection->delete(
670674
$optionTable,
671-
$this->connection->quoteInto('parent_id IN (?)', $productIdsInWhere)
675+
$this->connection->quoteInto('parent_id IN (?)', $productIds)
672676
);
673677
$this->connection->delete(
674-
$optionTable,
675-
$this->connection->quoteInto('parent_product_id IN (?)', $productIdsInWhere)
678+
$selectionTable,
679+
$this->connection->quoteInto('parent_product_id IN (?)', $productIds)
676680
);
677681
return $this;
678682
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private function isUniqueAdminValues(array $optionsValues, array $deletedOptions
128128
}
129129
}
130130
$uniqueValues = array_unique($adminValues);
131-
return ($uniqueValues === $adminValues);
131+
return array_diff_assoc($adminValues, $uniqueValues);
132132
}
133133

134134
/**
@@ -157,10 +157,16 @@ private function checkUniqueOption(DataObject $response, array $options = null)
157157
if (is_array($options)
158158
&& !empty($options['value'])
159159
&& !empty($options['delete'])
160-
&& !$this->isUniqueAdminValues($options['value'], $options['delete'])
161160
) {
162-
$this->setMessageToResponse($response, [__("The value of Admin must be unique.")]);
163-
$response->setError(true);
161+
$duplicates = $this->isUniqueAdminValues($options['value'], $options['delete']);
162+
if ($duplicates) {
163+
$this->setMessageToResponse(
164+
$response,
165+
[__('The value of Admin must be unique. (%1)', implode(', ', $duplicates))]
166+
);
167+
168+
$response->setError(true);
169+
}
164170
}
165171
return $this;
166172
}

app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media/ImageEntryConverter.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ public function convertFrom(ProductAttributeMediaGalleryEntryInterface $entry)
100100
protected function convertFromMediaGalleryEntryContentInterface(
101101
ImageContentInterface $content = null
102102
) {
103-
if ($content == null) {
103+
if ($content === null) {
104104
return null;
105-
} else {
106-
return [
107-
'data' => [
108-
ImageContentInterface::BASE64_ENCODED_DATA => $content->getBase64EncodedData(),
109-
ImageContentInterface::TYPE => $content->getType(),
110-
ImageContentInterface::NAME => $content->getName(),
111-
],
112-
];
113105
}
106+
107+
return [
108+
'data' => [
109+
ImageContentInterface::BASE64_ENCODED_DATA => $content->getBase64EncodedData(),
110+
ImageContentInterface::TYPE => $content->getType(),
111+
ImageContentInterface::NAME => $content->getName(),
112+
],
113+
];
114114
}
115115
}

app/code/Magento/Catalog/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,3 +717,4 @@ none,none
717717
Overview,Overview
718718
Details,Details
719719
"The value of Admin must be unique.", "The value of Admin must be unique."
720+
"The value of Admin must be unique. (%1)", "The value of Admin must be unique. (%1)"

app/code/Magento/Catalog/view/adminhtml/web/catalog/product/attribute/unique-validate.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ define([
1010
'use strict';
1111

1212
return function (config) {
13-
var _config = jQuery.extend({
14-
element: null,
15-
message: '',
16-
uniqueClass: 'required-unique'
17-
}, config);
13+
var msg = '',
14+
_config = jQuery.extend({
15+
element: null,
16+
message: '',
17+
uniqueClass: 'required-unique'
18+
}, config),
19+
20+
/** @inheritdoc */
21+
messager = function () {
22+
return msg;
23+
};
1824

1925
if (typeof _config.element === 'string') {
2026
jQuery.validator.addMethod(
@@ -25,21 +31,27 @@ define([
2531
.closest('table')
2632
.find('.' + _config.uniqueClass + ':visible'),
2733
valuesHash = {},
28-
isValid = true;
34+
isValid = true,
35+
duplicates = [];
2936

3037
inputs.each(function (el) {
3138
var inputValue = inputs[el].value;
3239

3340
if (typeof valuesHash[inputValue] !== 'undefined') {
3441
isValid = false;
42+
duplicates.push(inputValue);
3543
}
3644
valuesHash[inputValue] = el;
3745
});
3846

47+
if (!isValid) {
48+
msg = _config.message + ' (' + duplicates.join(', ') + ')';
49+
}
50+
3951
return isValid;
4052
},
4153

42-
_config.message
54+
messager
4355
);
4456
}
4557
};

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
4242
$pos = $block->getPositioned();
4343
?>
4444
<div class="products wrapper <?= /* @escapeNotVerified */ $viewMode ?> products-<?= /* @escapeNotVerified */ $viewMode ?>">
45-
<?php $iterator = 1; ?>
4645
<ol class="products list items product-items">
4746
<?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
4847
<?php foreach ($_productCollection as $_product): ?>
49-
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
48+
<li class="item product product-item">
5049
<div class="product-item-info" data-container="product-grid">
5150
<?php
5251
$productImage = $block->getImage($_product, $image);
@@ -112,7 +111,7 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
112111
</div>
113112
</div>
114113
</div>
115-
<?= ($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
114+
</li>
116115
<?php endforeach; ?>
117116
</ol>
118117
</div>

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ switch ($type = $block->getType()) {
174174
<?php endif; ?>
175175
<div class="products wrapper grid products-grid products-<?= /* @escapeNotVerified */ $type ?>">
176176
<ol class="products list items product-items">
177-
<?php $iterator = 1; ?>
178177
<?php foreach ($items as $_item): ?>
179178
<?php $available = ''; ?>
180179
<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
@@ -183,9 +182,9 @@ switch ($type = $block->getType()) {
183182
<?php endif; ?>
184183
<?php endif; ?>
185184
<?php if ($type == 'related' || $type == 'upsell'): ?>
186-
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product product-item" style="display: none;">' : '</li><li class="item product product-item" style="display: none;">' ?>
185+
<li class="item product product-item" style="display: none;">
187186
<?php else: ?>
188-
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
187+
<li class="item product product-item">
189188
<?php endif; ?>
190189
<div class="product-item-info <?= /* @escapeNotVerified */ $available ?>">
191190
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
@@ -252,7 +251,7 @@ switch ($type = $block->getType()) {
252251
<?php endif; ?>
253252
</div>
254253
</div>
255-
<?= ($iterator == count($items)+1) ? '</li>' : '' ?>
254+
</li>
256255
<?php endforeach ?>
257256
</ol>
258257
</div>

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

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -38,61 +38,60 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
3838
}
3939
?>
4040
<div class="products wrapper <?= /* @escapeNotVerified */ $viewMode ?>">
41-
<?php $iterator = 1; ?>
4241
<ol class="products list items">
4342
<?php foreach ($_productCollection as $_product): ?>
44-
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product">' : '</li><li class="item product">' ?>
45-
<div class="product">
46-
<?php // Product Image ?>
47-
<a href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>" class="product photo">
48-
<?= $block->getImage($_product, $image)->toHtml() ?>
49-
</a>
50-
<div class="product details">
51-
<?php
43+
<li class="item product">
44+
<div class="product">
45+
<?php // Product Image ?>
46+
<a href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>" class="product photo">
47+
<?= $block->getImage($_product, $image)->toHtml() ?>
48+
</a>
49+
<div class="product details">
50+
<?php
5251

53-
$info = [];
54-
$info['name'] = '<strong class="product name">'
55-
. ' <a href="' . $_product->getProductUrl() . '" title="'
56-
. $block->stripTags($_product->getName(), null, true) . '">'
57-
. $_helper->productAttribute($_product, $_product->getName(), 'name')
58-
. '</a></strong>';
59-
$info['price'] = $block->getProductPrice($_product);
60-
$info['review'] = $block->getReviewsSummaryHtml($_product, $templateType);
52+
$info = [];
53+
$info['name'] = '<strong class="product name">'
54+
. ' <a href="' . $_product->getProductUrl() . '" title="'
55+
. $block->stripTags($_product->getName(), null, true) . '">'
56+
. $_helper->productAttribute($_product, $_product->getName(), 'name')
57+
. '</a></strong>';
58+
$info['price'] = $block->getProductPrice($_product);
59+
$info['review'] = $block->getReviewsSummaryHtml($_product, $templateType);
6160

62-
if ($_product->isSaleable()) {
63-
$info['button'] = '<button type="button" title="' . __('Add to Cart') . '" class="action tocart"'
64-
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->getAddToCartUrl($_product) . '"} }\'>'
65-
. '<span>' . __('Add to Cart') . '</span></button>';
66-
} else {
67-
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . __('In stock') . '</span></div>' :
68-
'<div class="stock unavailable"><span>' . __('Out of stock') . '</span></div>';
69-
}
61+
if ($_product->isSaleable()) {
62+
$info['button'] = '<button type="button" title="' . __('Add to Cart') . '" class="action tocart"'
63+
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->getAddToCartUrl($_product) . '"} }\'>'
64+
. '<span>' . __('Add to Cart') . '</span></button>';
65+
} else {
66+
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . __('In stock') . '</span></div>' :
67+
'<div class="stock unavailable"><span>' . __('Out of stock') . '</span></div>';
68+
}
7069

71-
$info['links'] = '<div class="product links" data-role="add-to-links">'
72-
. '<a href="#" data-post=\'' . $this->helper('Magento\Wishlist\Helper\Data')->getAddParams($_product) . '\' class="action towishlist" data-action="add-to-wishlist">'
73-
. '<span>' . __('Add to Wish List') . '</span></a>'
74-
. '<a href="' . $block->getAddToCompareUrl($_product) . '" class="action tocompare">'
75-
. '<span>' . __('Add to Compare') . '</span></a></div>';
76-
$info['actions'] = '<div class="product action">' . $info['button'] . $info['links'] . '</div>';
70+
$info['links'] = '<div class="product links" data-role="add-to-links">'
71+
. '<a href="#" data-post=\'' . $this->helper('Magento\Wishlist\Helper\Data')->getAddParams($_product) . '\' class="action towishlist" data-action="add-to-wishlist">'
72+
. '<span>' . __('Add to Wish List') . '</span></a>'
73+
. '<a href="' . $block->getAddToCompareUrl($_product) . '" class="action tocompare">'
74+
. '<span>' . __('Add to Compare') . '</span></a></div>';
75+
$info['actions'] = '<div class="product action">' . $info['button'] . $info['links'] . '</div>';
7776

78-
if ($showDescription) {
79-
$info['description'] = '<div class="product description">'
80-
. $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description')
81-
. ' <a href="' . $_product->getProductUrl() . '" class="action more">'
82-
. __('Learn More') . '</a></div>';
83-
} else {
84-
$info['description'] = '';
85-
}
77+
if ($showDescription) {
78+
$info['description'] = '<div class="product description">'
79+
. $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description')
80+
. ' <a href="' . $_product->getProductUrl() . '" class="action more">'
81+
. __('Learn More') . '</a></div>';
82+
} else {
83+
$info['description'] = '';
84+
}
8685

87-
$details = $block->getInfoOrder() ?: ['name','price','review','description','actions'];
88-
foreach ($details as $detail) {
89-
/* @escapeNotVerified */ echo $info[$detail];
90-
}
91-
?>
86+
$details = $block->getInfoOrder() ?: ['name','price','review','description','actions'];
87+
foreach ($details as $detail) {
88+
/* @escapeNotVerified */ echo $info[$detail];
89+
}
90+
?>
9291

92+
</div>
9393
</div>
94-
</div>
95-
<?= ($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
94+
</li>
9695
<?php endforeach; ?>
9796
</ol>
9897
</div>

0 commit comments

Comments
 (0)