Q:

Views will not use pathauto URL Alias when listing programatically saved nodes

I am programatically saving nodes, and everything is working fine. Pathauto is working correctly as well and generating aliases based on my url alias configurations.
However, when Views creates a list of the new nodes, it uses node/xx instead of the existing url alias.  Anyone know why this could be happening? All caches have been cleared, cron ran, etc. Here is the code
$node = new stdClass();
    //set other defaults
    node_object_prepare($node);

    $node->type = $page_data['content_type'];
    $node->body[LANGUAGE_NONE][0]['value'] = $page_data['description'];
    $node->body[LANGUAGE_NONE][0]['summary'] = text_summary($page_data['description']);
    $node->body[LANGUAGE_NONE][0]['format']  = 'filtered_html';
    $node->title = $page_data['title'];
    $node->field_product_price[LANGUAGE_NONE][0]['value'] = $page_data['price'];
    $node->field_item_location[LANGUAGE_NONE][0]['postal_code'] = $page_data['zipcode'];
    $node->uid = "1";
    $node->status = 1;
    $node->active = 1;
    $node->pathauto_perform_alias = TRUE;

$node->field_product_images[LANGUAGE_NONE] = $images;
unset($images);

$node->field_baby_clothes_category[LANGUAGE_NONE][0]['tid'] = $page_data['category']; 

if($node = node_submit($node)) { // Prepare node for saving
    node_save($node);
}

note - when I add the same information through the content type form everthing works fine. It's almost as if my code is missing something that helps connect it to views.

A:

Ah, I found it. you need $node->language = LANGUAGE_NONE;
without it, Drupal does not have a language to assign it too. If you have local enabled, then $node->language has to equal 'en' or whatever your langauge is you're creating a link for.

