Skip to content

magento/magento2#7720 #26470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 18, 2020
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()
);
}
}