문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top