Question

I'm using the following code to try and update a product's description:

$product = $this->productRepository->getById(5);
$product->setData('description', 'foo');
$this->productRepository->save($product, $saveOptions = false);

While the data does get saved (I can fetch it correctly via $product->getData('description');), it is not changed in the db and thus no changes in the actual description. Are additional steps necessary or am I using a false approach entirely?

Was it helpful?

Solution

As it turns I was editing the wrong shop-language. Persisting the data actually worked the whole time.

It's a good idea to always use the storeId when getting the model-object form the repository.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top