Skip to content

Commit 4af0031

Browse files
committed
ACP2E-55: Simple only global attributes make configurable attributes hidden when creating product configurations
- Fixed the solution part.
1 parent b7db2b2 commit 4af0031

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProduct\Plugin\Model;
9+
10+
use Magento\ConfigurableProduct\Ui\DataProvider\Attributes;
11+
12+
/**
13+
* Update configurable product attribute collection.
14+
*/
15+
class UpdateConfigurableProductAttributeCollection
16+
{
17+
/**
18+
* Adding a field to filter in existing configurable product attribute collection.
19+
*
20+
* @param Attributes $subject
21+
* @return object
22+
*/
23+
public function beforeGetData(Attributes $subject): object
24+
{
25+
$types = [
26+
\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE,
27+
\Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL,
28+
\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE,
29+
];
30+
return $subject->getCollection()->addFieldToFilter(
31+
['apply_to', 'apply_to'],
32+
[
33+
['null' => true],
34+
['like' => '%' . implode(',', $types) . '%']
35+
]
36+
);
37+
}
38+
}

app/code/Magento/ConfigurableProduct/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,7 @@
8181
<type name="Magento\Sales\Model\Order\Invoice">
8282
<plugin name="update_configurable_product_total_qty" type="Magento\ConfigurableProduct\Plugin\Model\Order\Invoice\UpdateConfigurableProductTotalQty"/>
8383
</type>
84+
<type name="Magento\ConfigurableProduct\Ui\DataProvider\Attributes">
85+
<plugin name="update_configurable_product_attribute_collection" type="Magento\ConfigurableProduct\Plugin\Model\UpdateConfigurableProductAttributeCollection"/>
86+
</type>
8487
</config>

0 commit comments

Comments
 (0)