Hello,
I am trying to update the long description of an article programmatically and am having some difficulty doing so. It seems that should a product have variants then this does not work as expected and the data does not get persisted.
This is some example code which is not working for me:
$article = $this->getArticleRepository()->getArticleQuery(200)->execute();
$article = reset($article);
$article->fromArray([‘descriptionLong’ => ‘something’]);
Shopware()->Models()->persist($article);
Shopware()->Models()->flush();
I have tried this in other ways and have made an effort to try and do this in a similar way to how Shopware does it when saving in the admin.
Could you please let me know if there is anything wrong with this approach or if you are able to reproduce the problem? Debugging this issue it seems that Shopware thinks that the newly set data is the ‘old’ data. It also seems that loading any article that has a variant results in the name and description being missing. Loading one with no variant results in that data being present on the model.