Skip to content

Commit d3f18aa

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #14716: [2.2] Fix - minicart label fixed size issue (by @Karlasa) - #14715: #14669 Css class "empty" is always present on minicart dropdown (by @Karlasa) - #13397: #13296: Category name with special characters brakes � (by @vinayshah) - #14338: Fixing wrong sitemap product url #4788 (by @DenisSaltanahmedov) Fixed GitHub Issues: - #14669: Css class "empty" is always present on minicart dropdown (reported by @denistrator) has been fixed in #14715 by @Karlasa in 2.2-develop branch Related commits: 1. 888d828 - #13296: Category name with special characters brakes in url rewrites category tree (reported by @galanis-a) has been fixed in #13397 by @vinayshah in 2.2-develop branch Related commits: 1. 20396d5 2. a22b6fd 3. ff4f6cf 4. 934a0a3 5. 1bd6356 6. 4bdba36 7. e764e68 8. ac21097 9. b9821e9 10. 6fec232 11. c33d27f 12. fc510c4 13. f300c39 14. b747343 15. 851cc3a 16. af0f2e9 17. 05dfa6e - #4788: Wrong sitemap product url (reported by @teokolo) has been fixed in #14338 by @DenisSaltanahmedov in 2.2-develop branch Related commits: 1. 56811a8 2. 79621fb 3. ba5a5ff 4. b983a37
2 parents 8b36f39 + c4696ab commit d3f18aa

File tree

10 files changed

+160
-41
lines changed

10 files changed

+160
-41
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/category-tree.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
define([
77
'jquery',
8+
'mageUtils',
89
'jquery/ui',
910
'jquery/jstree/jquery.jstree'
10-
], function ($) {
11+
], function ($, utils) {
1112
'use strict';
1213

1314
$.widget('mage.categoryTree', {
@@ -88,9 +89,10 @@ define([
8889
if (!node) {
8990
return result;
9091
}
92+
9193
result = {
9294
data: {
93-
title: node.name + ' (' + node['product_count'] + ')'
95+
title: utils.unescape(node.name) + ' (' + node['product_count'] + ')'
9496
},
9597
attr: {
9698
'class': node.cls + (!!node.disabled ? ' disabled' : '') //eslint-disable-line no-extra-boolean-cast

app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</span>
2626
</a>
2727
<?php if ($block->getIsNeedToDisplaySideBar()): ?>
28-
<div class="block block-minicart empty"
28+
<div class="block block-minicart"
2929
data-role="dropdownDialog"
3030
data-mage-init='{"dropdownDialog":{
3131
"appendTo":"[data-block=minicart]",

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
99
use Magento\Store\Model\Store;
1010
use Magento\Framework\App\ObjectManager;
11+
use Magento\Store\Model\ScopeInterface;
12+
use Magento\Catalog\Helper\Product as HelperProduct;
1113

1214
/**
1315
* Sitemap resource product collection model
@@ -88,6 +90,13 @@ class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
8890
* @var \Magento\Catalog\Helper\Image
8991
*/
9092
private $catalogImageHelper;
93+
94+
/**
95+
* Scope Config
96+
*
97+
* @var \Magento\Framework\App\Config\ScopeConfigInterface
98+
*/
99+
private $scopeConfig;
91100

92101
/**
93102
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
@@ -102,6 +111,7 @@ class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
102111
* @param string $connectionName
103112
* @param \Magento\Catalog\Model\Product $productModel
104113
* @param \Magento\Catalog\Helper\Image $catalogImageHelper
114+
* @param \Magento\Framework\App\Config\ScopeConfigInterface|null $scopeConfig
105115
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
106116
*/
107117
public function __construct(
@@ -116,7 +126,8 @@ public function __construct(
116126
\Magento\Catalog\Model\Product\Media\Config $mediaConfig,
117127
$connectionName = null,
118128
\Magento\Catalog\Model\Product $productModel = null,
119-
\Magento\Catalog\Helper\Image $catalogImageHelper = null
129+
\Magento\Catalog\Helper\Image $catalogImageHelper = null,
130+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig = null
120131
) {
121132
$this->_productResource = $productResource;
122133
$this->_storeManager = $storeManager;
@@ -129,6 +140,8 @@ public function __construct(
129140
$this->productModel = $productModel ?: ObjectManager::getInstance()->get(\Magento\Catalog\Model\Product::class);
130141
$this->catalogImageHelper = $catalogImageHelper ?: ObjectManager::getInstance()
131142
->get(\Magento\Catalog\Helper\Image::class);
143+
$this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()
144+
->get(\Magento\Framework\App\Config\ScopeConfigInterface::class);
132145
parent::__construct($context, $connectionName);
133146
}
134147

@@ -272,6 +285,10 @@ public function getCollection($storeId)
272285
}
273286

274287
$connection = $this->getConnection();
288+
$urlsConfigCondition = '';
289+
if ($this->isCategoryProductURLsConfig($storeId)) {
290+
$urlsConfigCondition = 'NOT ';
291+
}
275292

276293
$this->_select = $connection->select()->from(
277294
['e' => $this->getMainTable()],
@@ -282,7 +299,8 @@ public function getCollection($storeId)
282299
[]
283300
)->joinLeft(
284301
['url_rewrite' => $this->getTable('url_rewrite')],
285-
'e.entity_id = url_rewrite.entity_id AND url_rewrite.is_autogenerated = 1 AND url_rewrite.metadata IS NULL'
302+
'e.entity_id = url_rewrite.entity_id AND url_rewrite.is_autogenerated = 1 AND url_rewrite.metadata IS '
303+
. $urlsConfigCondition . 'NULL'
286304
. $connection->quoteInto(' AND url_rewrite.store_id = ?', $store->getId())
287305
. $connection->quoteInto(' AND url_rewrite.entity_type = ?', ProductUrlRewriteGenerator::ENTITY_TYPE),
288306
['url' => 'request_path']
@@ -450,4 +468,20 @@ private function getProductImageUrl($image)
450468

451469
return $imgUrl;
452470
}
471+
472+
/**
473+
* Return Use Categories Path for Product URLs config value
474+
*
475+
* @param $storeId
476+
*
477+
* @return bool
478+
*/
479+
private function isCategoryProductURLsConfig($storeId)
480+
{
481+
return (bool)$this->scopeConfig->getValue(
482+
HelperProduct::XML_PATH_PRODUCT_URL_USE_CATEGORY,
483+
ScopeInterface::SCOPE_STORE,
484+
$storeId
485+
);
486+
}
453487
}

app/code/Magento/UrlRewrite/Block/Catalog/Category/Tree.php

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\UrlRewrite\Block\Catalog\Category;
78

9+
use Magento\Backend\Block\Widget\Context;
10+
use Magento\Backend\Helper\Data;
811
use Magento\Catalog\Api\CategoryRepositoryInterface;
12+
use Magento\Catalog\Block\Adminhtml\Category\AbstractCategory;
913
use Magento\Catalog\Model\Category;
14+
use Magento\Catalog\Model\CategoryFactory;
15+
use Magento\Catalog\Model\ProductFactory;
1016
use Magento\Framework\Exception\NoSuchEntityException;
17+
use Magento\Framework\Json\EncoderInterface;
18+
use Magento\Framework\Registry;
1119

1220
/**
1321
* Categories tree block for URL rewrites editing process
1422
*
1523
* @author Magento Core Team <core@magentocommerce.com>
1624
*/
17-
class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
25+
class Tree extends AbstractCategory
1826
{
1927
/**
2028
* List of allowed category ids
@@ -31,22 +39,22 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
3139
/**
3240
* Adminhtml data
3341
*
34-
* @var \Magento\Backend\Helper\Data
42+
* @var Data
3543
*/
3644
protected $_adminhtmlData = null;
3745

3846
/**
39-
* @var \Magento\Catalog\Model\CategoryFactory
47+
* @var CategoryFactory
4048
*/
4149
protected $_categoryFactory;
4250

4351
/**
44-
* @var \Magento\Catalog\Model\ProductFactory
52+
* @var ProductFactory
4553
*/
4654
protected $_productFactory;
4755

4856
/**
49-
* @var \Magento\Framework\Json\EncoderInterface
57+
* @var EncoderInterface
5058
*/
5159
protected $_jsonEncoder;
5260

@@ -56,24 +64,24 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
5664
protected $categoryRepository;
5765

5866
/**
59-
* @param \Magento\Backend\Block\Widget\Context $context
67+
* @param Context $context
6068
* @param \Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree
61-
* @param \Magento\Framework\Registry $registry
62-
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
63-
* @param \Magento\Catalog\Model\ProductFactory $productFactory
64-
* @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
65-
* @param \Magento\Backend\Helper\Data $adminhtmlData
69+
* @param Registry $registry
70+
* @param EncoderInterface $jsonEncoder
71+
* @param ProductFactory $productFactory
72+
* @param CategoryFactory $categoryFactory
73+
* @param Data $adminhtmlData
6674
* @param CategoryRepositoryInterface $categoryRepository
6775
* @param array $data
6876
*/
6977
public function __construct(
70-
\Magento\Backend\Block\Widget\Context $context,
78+
Context $context,
7179
\Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree,
72-
\Magento\Framework\Registry $registry,
73-
\Magento\Catalog\Model\CategoryFactory $categoryFactory,
74-
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
75-
\Magento\Catalog\Model\ProductFactory $productFactory,
76-
\Magento\Backend\Helper\Data $adminhtmlData,
80+
Registry $registry,
81+
CategoryFactory $categoryFactory,
82+
EncoderInterface $jsonEncoder,
83+
ProductFactory $productFactory,
84+
Data $adminhtmlData,
7785
CategoryRepositoryInterface $categoryRepository,
7886
array $data = []
7987
) {

app/code/Magento/UrlRewrite/view/adminhtml/templates/categories.phtml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@
88

99
/** @var \Magento\UrlRewrite\Block\Catalog\Category\Tree $block */
1010
?>
11-
<fieldset class="admin__fieldset" data-ui-id="category-selector">
12-
<legend class="admin__legend"><span><?= $block->escapeHtml(__('Select Category')) ?></span></legend>
13-
<div class="content content-category-tree">
14-
<input type="hidden" name="categories" id="product_categories" value="" />
15-
<?php if ($block->getRoot()): ?>
16-
<div data-mage-init='<?php /* @noEscape */ echo $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode(
17-
[
18-
'categoryTree' => [
19-
'data' => $block->getTreeArray(),
20-
'url' => $block->escapeUrl($block->getLoadTreeUrl()),
21-
],
22-
]
23-
); ?>' class="jstree-default"></div>
24-
<?php endif; ?>
25-
</div>
26-
</fieldset>
11+
<fieldset class="admin__fieldset" data-ui-id="category-selector">
12+
<legend class="admin__legend"><span><?= $block->escapeHtml(__('Select Category')) ?></span></legend>
13+
<div class="content content-category-tree">
14+
<input type="hidden" name="categories" id="product_categories" value=""/>
15+
<?php if ($block->getRoot()): ?>
16+
<div class="jstree-default"></div>
17+
<?php endif; ?>
18+
</div>
19+
</fieldset>
20+
<?php if ($block->getRoot()): ?>
21+
<script type="text/x-magento-init">
22+
{
23+
".jstree-default": {
24+
"categoryTree": {
25+
"data": <?php /* @noEscape */
26+
echo $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($block->getTreeArray()); ?>,
27+
"url": "<?php /* @noEscape */
28+
echo $block->escapeUrl($block->getLoadTreeUrl()); ?>"
29+
}
30+
}
31+
}
32+
</script>
33+
<?php endif; ?>

app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@
239239
.product-item-pricing {
240240
.label {
241241
display: inline-block;
242-
width: 4.5rem;
243242
}
244243
}
245244

app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@
249249
.product-item-pricing {
250250
.label {
251251
display: inline-block;
252-
width: 4.5rem;
253252
}
254253
}
255254

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var $category \Magento\Catalog\Model\Category */
8+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
9+
10+
$categoryFirst = $objectManager->create(\Magento\Catalog\Model\Category::class);
11+
$categoryFirst->setName('Category 1')
12+
->setPath('1/2')
13+
->setLevel(2)
14+
->setAvailableSortBy('name')
15+
->setDefaultSortBy('name')
16+
->setIsActive(true)
17+
->setPosition(1)
18+
->save();
19+
20+
// products from this fixture were moved to indexer_catalog_products.php
21+
$categorySecond = $objectManager->create(\Magento\Catalog\Model\Category::class);
22+
$categorySecond->setName('"Category 6"')
23+
->setPath($categoryFirst->getPath())
24+
->setLevel(3)
25+
->setAvailableSortBy('name')
26+
->setDefaultSortBy('name')
27+
->setIsActive(true)
28+
->setPosition(1)
29+
->save();

dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Category/TreeTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\UrlRewrite\Block\Catalog\Category;
78

89
/**
@@ -56,7 +57,27 @@ public function testGetTreeArrayApostropheReplaced()
5657
$tree = $this->_treeBlock->getTreeArray();
5758

5859
$this->assertNotContains('\'', $tree['children'][0]['children'][0]['children'][0]['name']);
59-
$this->assertEquals('&#039;Category 6&#039;', $tree['children'][0]['children'][0]['children'][0]['name']);
60+
$this->assertEquals(
61+
'&#039;Category 6&#039;',
62+
$tree['children'][0]['children'][0]['children'][0]['name']
63+
);
64+
}
65+
66+
/**
67+
* Test that the getTreeArray() method scrubs single quotes and apostrophes from names
68+
*
69+
* @magentoAppIsolation enabled
70+
* @magentoDataFixture Magento/Catalog/_files/catalog_category_with_doublequotes.php
71+
*/
72+
public function testGetTreeArrayDoubleQuotesReplaced()
73+
{
74+
$tree = $this->_treeBlock->getTreeArray();
75+
76+
$this->assertNotContains('\"', $tree['children'][0]['children'][0]['children'][0]['name']);
77+
$this->assertEquals(
78+
'&quot;Category 6&quot;',
79+
$tree['children'][0]['children'][0]['children'][0]['name']
80+
);
6081
}
6182

6283
/**

lib/web/mage/utils/misc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,26 @@ define([
242242
return data;
243243
},
244244

245+
/**
246+
* Replaces symbol codes with their unescaped counterparts.
247+
*
248+
* @param {String} data
249+
*
250+
* @returns {String}
251+
*/
252+
unescape: function (data) {
253+
var unescaped = _.unescape(data),
254+
mapCharacter = {
255+
'&#039;': '\''
256+
};
257+
258+
_.each(mapCharacter, function (value, key) {
259+
unescaped = unescaped.replace(key, value);
260+
});
261+
262+
return unescaped;
263+
},
264+
245265
/**
246266
* Converts PHP IntlFormatter format to moment format.
247267
*

0 commit comments

Comments
 (0)