Skip to content

Commit a99d46e

Browse files
committed
AC-4958: Multiselect/select attribute options can be saved when Swatches modules disabled
1 parent 9ac92f6 commit a99d46e

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\ViewModel\Attribute;
9+
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
use Magento\Catalog\Helper\Data as CatalogHelper;
12+
13+
class ProductAttributeHelper implements ArgumentInterface
14+
{
15+
private CatalogHelper $catalogHelper;
16+
17+
public function __construct(CatalogHelper $catalogHelper)
18+
{
19+
$this->catalogHelper = $catalogHelper;
20+
}
21+
22+
public function getCatalogHelper(): CatalogHelper
23+
{
24+
return $this->catalogHelper;
25+
}
26+
}

‎app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_attribute_edit.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2014 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
@@ -22,7 +22,11 @@
2222
<block class="Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit" name="attribute_edit_content"/>
2323
</referenceContainer>
2424
<referenceContainer name="js">
25-
<block class="Magento\Backend\Block\Template" name="attribute_edit_js" template="Magento_Catalog::catalog/product/attribute/js.phtml"/>
25+
<block class="Magento\Backend\Block\Template" name="attribute_edit_js" template="Magento_Catalog::catalog/product/attribute/js.phtml">
26+
<arguments>
27+
<argument name="view_model" xsi:type="object">Magento\Catalog\ViewModel\Attribute\ProductAttributeHelper</argument>
28+
</arguments>
29+
</block>
2630
</referenceContainer>
2731
</body>
2832
</page>

‎app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use Magento\Catalog\Helper\Data;
1414
/** @var \Magento\Framework\Json\Helper\Data $jsonHelper */
1515
$jsonHelper = $block->getData('jsonHelper');
1616
if (!method_exists($jsonHelper, 'getAttributeHiddenFields')) {
17-
$jsonHelper = $this->helper(Data::class);
17+
/** @var \Magento\Catalog\ViewModel\Attribute\ProductAttributeHelper $viewModel */
18+
$viewModel = $block->getViewModel();
19+
$jsonHelper = $viewModel->getCatalogHelper();
1820
}
1921
$scriptString = <<<script
2022
require([

0 commit comments

Comments
 (0)