I'm trying to change 600 products so that the node SKU is set to the value of the node's title. I want to use VBO to accomplish this, with the "execute arbitrary PHP script" option. Here is the code I am using:
$new_node = node_load($object->nid);
$new_node->model = $object->title;
node_save($new_node);
However, this does not work. Does anyone know where I'm going wrong here?
why not just set the sku with tokens.
For Drupal commerce you use: http://drupal.org/project/commerce_autosku
For ubercart: http://drupal.org/project/uc_product_power_tools
Once you set up the token rule then all you need to do is load and save all the nodes.
Not real sure what your code above is doing. I would use the devel execute php page and just run a one time script. Something like:
$sql = 'select nid from {node}'
$results = db_query($sql);
while ($nid = db_result($result)) {
$node = node_load($nid);
node_save($node);
}
Been a while since I've used drupal 6 database api so I probably botched the functions above but it should give you the right idea.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.