Skip to content

Commit 2073251

Browse files
committed
AC-13264: Downloadable product title enhancement
1 parent bca0482 commit 2073251

File tree

3 files changed

+13
-9
lines changed
  • app/code/Magento/Customer
    • Block/Adminhtml/Edit/Tab/View/Grid/Renderer
    • Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer
  • dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Grid/Renderer

3 files changed

+13
-9
lines changed

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/Item.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View\Grid\Renderer;
79

810
use Magento\Catalog\Model\Product;
@@ -123,7 +125,8 @@ public function render(\Magento\Framework\DataObject $item)
123125
$this->setItem($item);
124126
$product = $this->getProduct();
125127
$options = $this->getOptionList();
126-
return $options ? $this->_renderItemOptions($product, $options) : $this->escapeHtml($product->getName());
128+
return $options ? $this->_renderItemOptions($product, $options)
129+
: $this->_escaper->escapeHtml($product->getName());
127130
}
128131

129132
/**
@@ -135,13 +138,13 @@ public function render(\Magento\Framework\DataObject $item)
135138
*/
136139
protected function _renderItemOptions(Product $product, array $options)
137140
{
138-
$html = '<div class="product-title">' . $this->escapeHtml(
141+
$html = '<div class="product-title">' . $this->_escaper->escapeHtml(
139142
$product->getName()
140143
) . '</div>' . '<dl class="item-options">';
141144
foreach ($options as $option) {
142145
$formattedOption = $this->getFormattedOptionValue($option);
143-
$html .= '<dt>' . $this->escapeHtml($option['label']) . '</dt>';
144-
$html .= '<dd>' . $formattedOption['value'] . '</dd>';
146+
$html .= '<dt>' . $this->_escaper->escapeHtml($option['label']) . '</dt>';
147+
$html .= '<dd>' . $this->_escaper->escapeHtml($formattedOption['value']) . '</dd>';
145148
}
146149
$html .= '</dl>';
147150

app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public function testRender($amountOption, $expectedHtml)
115115
*/
116116
public function optionHtmlProvider()
117117
{
118+
//phpcs:disable
118119
return [
119120
[
120121
2,
@@ -123,9 +124,9 @@ public function optionHtmlProvider()
123124
<div class="product-title">testProductName</div>
124125
<dl class="item-options">
125126
<dt>testLabel1</dt>
126-
<dd>1 x Configurable Product 49-option 3 <span class="price">$10.00</span></dd>
127+
<dd>1 x Configurable Product 49-option 3 &lt;span class="price"&gt;$10.00&lt;/span&gt;</dd>
127128
<dt>testLabel2</dt>
128-
<dd>1 x Configurable Product 49-option 3 <span class="price">$10.00</span></dd>
129+
<dd>1 x Configurable Product 49-option 3 &lt;span class="price"&gt;$10.00&lt;/span&gt;</dd>
129130
</dl>
130131
</xhtml>
131132
HTML
@@ -137,11 +138,11 @@ public function optionHtmlProvider()
137138
<div class="product-title">testProductName</div>
138139
<dl class="item-options">
139140
<dt>testLabel1</dt>
140-
<dd>1 x Configurable Product 49-option 3 <span class="price">$10.00</span></dd>
141+
<dd>1 x Configurable Product 49-option 3 &lt;span class="price"&gt;$10.00&lt;/span&gt;</dd>
141142
</dl>
142143
</xhtml>
143144
HTML
144145
],
145-
];
146+
];//phpcs:enable
146147
}
147148
}

dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/AbstractItemTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private function getOptionsValueXPath(Item $quoteItem): array
109109
if (isset($option['option_type'])
110110
&& $option['option_type'] == ProductCustomOptionInterface::OPTION_GROUP_FILE) {
111111
$value = explode(" ", $option['print_value']);
112-
$options[$key]['xpath'] .= "/a[contains(text(), '{$value[0]}')]";
112+
$options[$key]['xpath'] .= "[contains(text(), '{$value[0]}')]";
113113
} else {
114114
$options[$key]['xpath'] .= "[contains(text(), '{$option['value']}')]";
115115
}

0 commit comments

Comments
 (0)