Jump to content

Can't change page title via API.


Jason Huck
 Share

Recommended Posts

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

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

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

 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...