Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim committed Jan 21, 2020
1 parent c2e2646 commit 042df41
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/code/Magento/Catalog/Model/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,9 @@ public function save(ProductInterface $product, $saveOptions = false)
if (!$ignoreLinksFlag && $ignoreLinksFlag !== null) {
$productLinks = $product->getProductLinks();
}
$productDataArray['store_id'] = (int)$this->storeManager->getStore()->getId();
if (!isset($productDataArray['store_id'])) {
$productDataArray['store_id'] = (int) $this->storeManager->getStore()->getId();
}
$product = $this->initializeProductData($productDataArray, empty($existingProduct));

$this->processLinks($product, $productLinks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,24 @@ public function testCustomLayout(): void
}
$this->assertTrue($caughtException);
}

/**
* Tests product repository update should use provided store code.
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*/
public function testProductUpdate(): void
{
$sku = 'simple';
$nameUpdated = 'updated';

$product = $this->productRepository->get($sku, false, 0);
$product->setName($nameUpdated);
$this->productRepository->save($product);
$product = $this->productRepository->get($sku, false, 0);
self::assertEquals(
$nameUpdated,
$product->getName()
);
}
}

0 comments on commit 042df41

Please sign in to comment.