|
6 | 6 | namespace Magento\Catalog\Setup;
|
7 | 7 |
|
8 | 8 | use Magento\Catalog\Api\Data\ProductAttributeInterface;
|
| 9 | +use Magento\Eav\Model\AttributeRepository; |
9 | 10 | use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
|
10 | 11 | use Magento\Framework\Setup\UpgradeDataInterface;
|
11 | 12 | use Magento\Framework\Setup\ModuleContextInterface;
|
@@ -40,8 +41,11 @@ class UpgradeData implements UpgradeDataInterface
|
40 | 41 | * @param CategorySetupFactory $categorySetupFactory
|
41 | 42 | * @param EavSetupFactory $eavSetupFactory
|
42 | 43 | */
|
43 |
| - public function __construct(CategorySetupFactory $categorySetupFactory, EavSetupFactory $eavSetupFactory) |
44 |
| - { |
| 44 | + public function __construct( |
| 45 | + CategorySetupFactory $categorySetupFactory, |
| 46 | + EavSetupFactory $eavSetupFactory, |
| 47 | + AttributeRepository $attributeRepository |
| 48 | + ) { |
45 | 49 | $this->categorySetupFactory = $categorySetupFactory;
|
46 | 50 | $this->eavSetupFactory = $eavSetupFactory;
|
47 | 51 | }
|
@@ -360,9 +364,36 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
|
360 | 364 | $this->changePriceAttributeDefaultScope($categorySetup);
|
361 | 365 | }
|
362 | 366 |
|
| 367 | + if (version_compare($context->getVersion(), '2.1.5') < 0) { |
| 368 | + $this->dissallowUsingHtmlForProductName($setup); |
| 369 | + } |
| 370 | + |
363 | 371 | $setup->endSetup();
|
364 | 372 | }
|
365 | 373 |
|
| 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 | + |
366 | 397 | /**
|
367 | 398 | * @param \Magento\Catalog\Setup\CategorySetup $categorySetup
|
368 | 399 | * @return void
|
|
0 commit comments