Skip to content

Commit 37150ff

Browse files
committed
MAGETWO-91497: Product websites are not honored
1 parent 943e2cd commit 37150ff

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -345,30 +345,27 @@ protected function initializeProductData(array $productData, $createNew)
345345
foreach ($productData as $key => $value) {
346346
$product->setData($key, $value);
347347
}
348-
$this->assignProductToWebsites($product, $createNew);
348+
if ($createNew) {
349+
$this->assignProductToWebsites($product);
350+
}
349351

350352
return $product;
351353
}
352354

353355
/**
354356
* @param \Magento\Catalog\Model\Product $product
355-
* @param bool $createNew
356357
* @return void
357358
*/
358-
private function assignProductToWebsites(\Magento\Catalog\Model\Product $product, $createNew)
359+
private function assignProductToWebsites(\Magento\Catalog\Model\Product $product)
359360
{
360-
$websiteIds = $product->getWebsiteIds();
361-
362-
if (!$this->storeManager->hasSingleStore()) {
363-
$websiteIds = array_unique(
364-
array_merge(
365-
$websiteIds,
366-
[$this->storeManager->getStore()->getWebsiteId()]
367-
)
368-
);
369-
}
361+
$websiteIds = array_unique(
362+
array_merge(
363+
$product->getWebsiteIds(),
364+
[$this->storeManager->getStore()->getWebsiteId()]
365+
)
366+
);
370367

371-
if ($createNew && $this->storeManager->getStore(true)->getCode() == \Magento\Store\Model\Store::ADMIN_CODE) {
368+
if ($this->storeManager->getStore(true)->getCode() == \Magento\Store\Model\Store::ADMIN_CODE) {
372369
$websiteIds = array_keys($this->storeManager->getWebsites());
373370
}
374371

0 commit comments

Comments
 (0)