Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 223099e

Browse files
author
Oleksii Korshenko
authored
MAGETWO-82313: [Backport 2.2-develop] #11324 REST API - Only associate automatically product with all websites when creating product in All Store Views scope #11444
2 parents 33574a3 + 78d0632 commit 223099e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,16 +340,17 @@ protected function initializeProductData(array $productData, $createNew)
340340
foreach ($productData as $key => $value) {
341341
$product->setData($key, $value);
342342
}
343-
$this->assignProductToWebsites($product);
343+
$this->assignProductToWebsites($product, $createNew);
344344

345345
return $product;
346346
}
347347

348348
/**
349349
* @param \Magento\Catalog\Model\Product $product
350+
* @param bool $createNew
350351
* @return void
351352
*/
352-
private function assignProductToWebsites(\Magento\Catalog\Model\Product $product)
353+
private function assignProductToWebsites(\Magento\Catalog\Model\Product $product, $createNew)
353354
{
354355
$websiteIds = $product->getWebsiteIds();
355356

@@ -362,7 +363,7 @@ private function assignProductToWebsites(\Magento\Catalog\Model\Product $product
362363
);
363364
}
364365

365-
if ($this->storeManager->getStore(true)->getCode() == \Magento\Store\Model\Store::ADMIN_CODE) {
366+
if ($createNew && $this->storeManager->getStore(true)->getCode() == \Magento\Store\Model\Store::ADMIN_CODE) {
366367
$websiteIds = array_keys($this->storeManager->getWebsites());
367368
}
368369

0 commit comments

Comments
 (0)