function uc_catalog_orphaned_products in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_catalog/uc_catalog.module \uc_catalog_orphaned_products()
- 6.2 uc_catalog/uc_catalog.admin.inc \uc_catalog_orphaned_products()
Displays links to all products that have not been categorized.
1 string reference to 'uc_catalog_orphaned_products'
- uc_catalog_menu in uc_catalog/
uc_catalog.module - Implements hook_menu().
File
- uc_catalog/
uc_catalog.admin.inc, line 64 - Catalog administration menu items.
Code
function uc_catalog_orphaned_products() {
$build = array();
if (variable_get('taxonomy_maintain_index_table', TRUE)) {
$vid = variable_get('uc_catalog_vid', 0);
$product_types = uc_product_types();
$field = field_info_field('taxonomy_catalog');
$types = array_intersect($product_types, $field['bundles']['node']);
$result = db_query("SELECT DISTINCT n.nid, n.title FROM {node} n LEFT JOIN (SELECT ti.nid, td.vid FROM {taxonomy_index} ti LEFT JOIN {taxonomy_term_data} td ON ti.tid = td.tid WHERE td.vid = :vid) txnome ON n.nid = txnome.nid WHERE n.type IN (:types) AND txnome.vid IS NULL", array(
':vid' => $vid,
':types' => $types,
));
$rows = array();
while ($node = $result
->fetchObject()) {
$rows[] = l($node->title, 'node/' . $node->nid . '/edit', array(
'query' => array(
'destination' => 'admin/store/products/orphans',
),
));
}
if (count($rows) > 0) {
$build['orphans'] = array(
'#theme' => 'item_list',
'#items' => $rows,
);
}
else {
$build['orphans'] = array(
'#markup' => t('All products are currently listed in the catalog.'),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
}
}
else {
$build['orphans'] = array(
'#markup' => t('The node terms index is not being maintained, so Ubercart can not determine which products are not entered into the catalog.'),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
}
return $build;
}