Jason Huck Posted May 9, 2020 Share Posted May 9, 2020 We have a routine that imports product data from an external source and adds, updates, or deletes pages as needed. We've realized that existing page titles aren't being updated. The page name and other fields get updated, including a custom field that we set up to be identical to the title field. The title field is a TextLanguage field. There is currently only the default language (English). Is there some special step you have to take for page titles, multilingual or otherwise? I've done similar things in the past and don't ever recall having this issue. I've tried each of these to no avail: $product->title = $productTitle; $product->set('title', $productTitle); $product->title->setLanguageValue(wire('languages')->get('default'), $productTitle); $product->title->setLanguageValue(wire('languages')->get('english'), $productTitle); Thanks, Jason Link to comment Share on other sites More sharing options...
kixe Posted May 10, 2020 Share Posted May 10, 2020 $product->of(false); $product->title = $productTitle; $product->save(); in short: $product->setAndSave('title',$productTitle); Link to comment Share on other sites More sharing options...
Jason Huck Posted May 11, 2020 Author Share Posted May 11, 2020 Hi kixe, Yes, I am turning output formatting off prior to the changes, and saving after making them. It does make me wonder if there is some other part of the routine that is overwriting the changes, though, so maybe I will separately set the title at the very end -- in its own save operation -- to see if that makes any difference. Thanks, Jason Link to comment Share on other sites More sharing options...
Jason Huck Posted May 12, 2020 Author Share Posted May 12, 2020 Well, I don't understand why, but saving the title in a discrete operation separate from other fields seems to work. In other words, this works for everything except the title: $product->of(false); $product->foo = 'bar'; $product->baz = 'yadda'; // ...etc... $product->title = 'hmm'; // does not work $product->save(); Whereas this seems to work for everything including the title: $product->of(false); $product->foo = 'bar'; $product->baz = 'yadda'; ...etc... $product->save(); $product->setAndSave(title', 'hmm'); // works fine 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now