diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index 4927a191467239c5c3fdaff033856e4e877de8c7..e814dc03cf37f655d2b520718685d28b5aad59e8 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -340,16 +340,17 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa foreach ($productData as $key => $value) { $product->setData($key, $value); } - $this->assignProductToWebsites($product); + $this->assignProductToWebsites($product, $createNew); return $product; } /** * @param \Magento\Catalog\Model\Product $product + * @param bool $createNew * @return void */ - private function assignProductToWebsites(\Magento\Catalog\Model\Product $product) + private function assignProductToWebsites(\Magento\Catalog\Model\Product $product, $createNew) { $websiteIds = $product->getWebsiteIds(); @@ -362,7 +363,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa ); } - if ($this->storeManager->getStore(true)->getCode() == \Magento\Store\Model\Store::ADMIN_CODE) { + if ($createNew && $this->storeManager->getStore(true)->getCode() == \Magento\Store\Model\Store::ADMIN_CODE) { $websiteIds = array_keys($this->storeManager->getWebsites()); }