Skip to content

Commit 7df797e

Browse files
author
Eric Bohanon
committed
MAGETWO-70779: Add URL Rewrite not retrieving categories
- CR changes
1 parent 4841a21 commit 7df797e

File tree

4 files changed

+6
-28
lines changed

4 files changed

+6
-28
lines changed

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

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ public function getTreeArray($parentId = null, $asJson = false, $recursionLevel
119119
$result = $this->_getNodesArray($this->getRoot(null, $recursionLevel));
120120
}
121121

122-
$result = $this->convertNameSingleQuote($result);
123-
124122
if ($asJson) {
125123
return $this->_jsonEncoder->encode($result);
126124
}
@@ -163,7 +161,8 @@ protected function _getNodesArray($node)
163161
'parent_id' => (int)$node->getParentId(),
164162
'children_count' => (int)$node->getChildrenCount(),
165163
'is_active' => (bool)$node->getIsActive(),
166-
'name' => $node->getName(),
164+
// Scrub names for raw js output
165+
'name' => $this->escapeHtml($node->getName()),
167166
'level' => (int)$node->getLevel(),
168167
'product_count' => (int)$node->getProductCount(),
169168
];
@@ -184,27 +183,6 @@ protected function _getNodesArray($node)
184183
return $result;
185184
}
186185

187-
/**
188-
* Scrubs category names of single quotes, replacing them with HTML Entity equivalent
189-
*
190-
* @param array $node
191-
* @return array
192-
*/
193-
private function convertNameSingleQuote($node)
194-
{
195-
if (!empty($node['name']) && strpos($node['name'], '\'') !== false) {
196-
$node['name'] = str_replace('\'', ''', $node['name']);
197-
}
198-
199-
// Recurse through all children
200-
$childrenCount = !empty($node['children']) ? count($node['children']) : 0;
201-
for ($i = 0; $i < $childrenCount; $i++) {
202-
$node['children'][$i] = $this->convertNameSingleQuote($node['children'][$i]);
203-
}
204-
205-
return $node;
206-
}
207-
208186
/**
209187
* Get URL for categories tree ajax loader
210188
*

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ public function testGetTreeArray()
4646
}
4747

4848
/**
49-
* Test that the getTree() method scrubs single quotes and apostrophes from names
49+
* Test that the getTreeArray() method scrubs single quotes and apostrophes from names
5050
*
5151
* @magentoAppIsolation enabled
52-
* @magentoDataFixture Magento/Catalog/_files/indexer_catalog_category_with_apostrophe.php
53-
* @magentoDataFixture Magento/Catalog/_files/indexer_catalog_products.php
52+
* @magentoDataFixture Magento/Catalog/_files/catalog_category_with_apostrophe.php
5453
*/
5554
public function testGetTreeArrayApostropheReplaced()
5655
{
5756
$tree = $this->_treeBlock->getTreeArray();
5857

59-
$this->assertContains('&apos;', $tree['children'][0]['children'][0]['children'][0]['name']);
58+
$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']);
6060
}
6161

6262
/**

0 commit comments

Comments
 (0)