3

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?

3
  • i believe you need to prepare the node for editing. see if node_object_prepare($new_node); will help you out. node_object_prepare – au_stan Dec 27 '12 at 16:41
  • did u use std class? – monymirza Dec 27 '12 at 17:08
  • I ended up using uc_product_power_tools and then looping through my products with a php script to update. Thanks for you help – Stephen Topsy Jan 8 '13 at 16:59
1

The only way I could get it to work was to do this:

$node->model = $sku;
node_save($node);

The reason I could not get values was because of revisions. I changed function "uc_product_get_models". Line 1357 changed to:

 $models[] = db_query('SELECT model FROM {uc_products} WHERE nid = :nid order by vid desc', array(':nid' => $nid))->fetchField();

I know changing core is bad, but:

  • It seems to be fixed in the dev version
  • I have no idea when the dev version is going to be released again, but when it does, the change will already be there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.