7
7
8
8
namespace Magento \Catalog \Controller \Adminhtml \Product ;
9
9
10
+ use Magento \Catalog \Api \Data \ProductInterface ;
10
11
use Magento \Catalog \Model \ProductFactory ;
11
12
use Magento \Cms \Model \Wysiwyg as WysiwygModel ;
12
13
use Magento \Framework \App \RequestInterface ;
@@ -86,11 +87,11 @@ public function __construct(
86
87
* Build product based on user request
87
88
*
88
89
* @param RequestInterface $request
89
- * @return \Magento\Catalog\Model\Product
90
+ * @return ProductInterface
90
91
* @throws \RuntimeException
91
92
* @throws \Magento\Framework\Exception\LocalizedException
92
93
*/
93
- public function build (RequestInterface $ request ): Product
94
+ public function build (RequestInterface $ request ): ProductInterface
94
95
{
95
96
$ productId = (int ) $ request ->getParam ('id ' );
96
97
$ storeId = $ request ->getParam ('store ' , 0 );
@@ -100,7 +101,9 @@ public function build(RequestInterface $request): Product
100
101
if ($ productId ) {
101
102
try {
102
103
$ product = $ this ->productRepository ->getById ($ productId , true , $ storeId );
103
- $ product ->setAttributeSetId ($ attributeSetId );
104
+ if ($ attributeSetId ) {
105
+ $ product ->setAttributeSetId ($ attributeSetId );
106
+ }
104
107
} catch (\Exception $ e ) {
105
108
$ product = $ this ->createEmptyProduct (ProductTypes::DEFAULT_TYPE , $ attributeSetId , $ storeId );
106
109
$ this ->logger ->critical ($ e );
0 commit comments