Skip to content

Commit f14ffca

Browse files
committed
MAGETWO-98357: The required product attribute is not displayed when change attribute set
1 parent 1766f4c commit f14ffca

File tree

1 file changed

+12
-1
lines changed
  • app/code/Magento/Catalog/Controller/Adminhtml/Product

1 file changed

+12
-1
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php

Lines changed: 12 additions & 1 deletion
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\Catalog\Controller\Adminhtml\Product;
79

810
use Magento\Catalog\Model\ProductFactory;
@@ -15,6 +17,11 @@
1517
use Magento\Catalog\Model\Product;
1618
use Magento\Catalog\Model\Product\Type as ProductTypes;
1719

20+
/**
21+
* Build a product based on a request
22+
*
23+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
24+
*/
1825
class Builder
1926
{
2027
/**
@@ -81,8 +88,9 @@ public function __construct(
8188
* @param RequestInterface $request
8289
* @return \Magento\Catalog\Model\Product
8390
* @throws \RuntimeException
91+
* @throws \Magento\Framework\Exception\LocalizedException
8492
*/
85-
public function build(RequestInterface $request)
93+
public function build(RequestInterface $request): Product
8694
{
8795
$productId = (int) $request->getParam('id');
8896
$storeId = $request->getParam('store', 0);
@@ -92,6 +100,7 @@ public function build(RequestInterface $request)
92100
if ($productId) {
93101
try {
94102
$product = $this->productRepository->getById($productId, true, $storeId);
103+
$product->setAttributeSetId($attributeSetId);
95104
} catch (\Exception $e) {
96105
$product = $this->createEmptyProduct(ProductTypes::DEFAULT_TYPE, $attributeSetId, $storeId);
97106
$this->logger->critical($e);
@@ -113,6 +122,8 @@ public function build(RequestInterface $request)
113122
}
114123

115124
/**
125+
* Create a product with the given properties
126+
*
116127
* @param int $typeId
117128
* @param int $attributeSetId
118129
* @param int $storeId

0 commit comments

Comments
 (0)