Jump to content

setName for children


Recommended Posts

So I'm trying to use setName as a way to change the name of about 1000 child pages because I need it to be different. I wrote the code an it works because it is changing the URL but not the "name" of the page. What am I doing wrong?
 

<?php
foreach($page->children() as $child){
	$sku = str_replace(' ', '-', strtolower($child->upc));
	$page->setName($sku);
}
?>

What am I doing wrong? the UPC changes. but the page name does not.

 

Thanks

Link to comment
Share on other sites

15 minutes ago, bernhard said:

Do you save the page after changing its name?

OMG you're a genius. I don't know how I missed that, but thanks. I just needed to run $child->save(); 

thanks

  • 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...