Skip to content

Commit 8f52de7

Browse files
author
Sergii Kovalenko
committed
MAGETWO-64716: Product name ignores HTML tags and displays plain text
1 parent a4f269e commit 8f52de7

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

app/code/Magento/Catalog/Setup/UpgradeData.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Setup;
77

88
use Magento\Catalog\Api\Data\ProductAttributeInterface;
9+
use Magento\Eav\Model\AttributeRepository;
910
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
1011
use Magento\Framework\Setup\UpgradeDataInterface;
1112
use Magento\Framework\Setup\ModuleContextInterface;
@@ -40,8 +41,11 @@ class UpgradeData implements UpgradeDataInterface
4041
* @param CategorySetupFactory $categorySetupFactory
4142
* @param EavSetupFactory $eavSetupFactory
4243
*/
43-
public function __construct(CategorySetupFactory $categorySetupFactory, EavSetupFactory $eavSetupFactory)
44-
{
44+
public function __construct(
45+
CategorySetupFactory $categorySetupFactory,
46+
EavSetupFactory $eavSetupFactory,
47+
AttributeRepository $attributeRepository
48+
) {
4549
$this->categorySetupFactory = $categorySetupFactory;
4650
$this->eavSetupFactory = $eavSetupFactory;
4751
}
@@ -360,9 +364,36 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
360364
$this->changePriceAttributeDefaultScope($categorySetup);
361365
}
362366

367+
if (version_compare($context->getVersion(), '2.1.5') < 0) {
368+
$this->dissallowUsingHtmlForProductName($setup);
369+
}
370+
363371
$setup->endSetup();
364372
}
365373

374+
/**
375+
* Set to 'No' 'Is Allowed Html on Store Front' option on product name attribute, because product name
376+
* is multi entity field (used in order, quote) and cannot be conditionally escaped in all places
377+
*
378+
* @param ModuleDataSetupInterface $categorySetup
379+
* @return void
380+
*/
381+
private function dissallowUsingHtmlForProductName(ModuleDataSetupInterface $setup)
382+
{
383+
/** @var CategorySetup $categorySetup */
384+
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
385+
$entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
386+
$attribute = $categorySetup->getAttribute($entityTypeId, 'name');
387+
388+
$setup->getConnection()
389+
->update(
390+
$setup->getTable('catalog_eav_attribute'),
391+
['is_html_allowed_on_front' => 0],
392+
$setup->getConnection()->quoteInto('attribute_id = ?', $attribute['attribute_id'])
393+
);
394+
395+
}
396+
366397
/**
367398
* @param \Magento\Catalog\Setup\CategorySetup $categorySetup
368399
* @return void

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Catalog" setup_version="2.1.4">
9+
<module name="Magento_Catalog" setup_version="2.1.5">
1010
<sequence>
1111
<module name="Magento_Eav"/>
1212
<module name="Magento_Cms"/>

0 commit comments

Comments
 (0)