function uc_catalog_store_status in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_catalog/uc_catalog.module \uc_catalog_store_status()
Implementation of Übercart's hook_store_status().
Provide status information about the "Product Catalog" and products not listed in the catalog.
File
- uc_catalog/
uc_catalog.module, line 486 - Übercart Catalog module.
Code
function uc_catalog_store_status() {
$statuses = array();
$cat_id = variable_get('uc_catalog_vid', 0);
$catalog = taxonomy_get_vocabulary($cat_id);
if ($catalog) {
$statuses[] = array(
'status' => 'ok',
'title' => t('Catalog vocabulary'),
'desc' => t('Vocabulary !name has been identified as the !uber catalog.', array(
'!name' => l($catalog->name, 'admin/content/taxonomy/' . $catalog->vid),
'!uber' => 'Übercart',
)),
);
$excluded = 0;
$result = db_query("SELECT DISTINCT * FROM {node} AS n LEFT JOIN {term_node} AS tn ON n.nid = tn.nid LEFT JOIN {vocabulary_node_types} AS vnt ON n.type = vnt.type WHERE n.type != 'image' AND tn.tid IS NULL AND vnt.vid = %d", $cat_id);
$excluded = db_num_rows($result);
if ($excluded) {
$description = format_plural($excluded, 'There is @count product not listed in the catalog.', 'There are @count products not listed in the catalog.') . t(' Products are listed by assigning a category from the <a href="!cat_url">Product Catalog</a> vocabulary to them.', array(
'!cat_url' => url('admin/content/taxonomy/' . $catalog->vid),
));
$terms = db_result(db_query("SELECT COUNT(*) FROM {term_data} WHERE vid = %d", $catalog->vid));
if ($terms) {
$description .= ' ' . l(t('Find orphaned products here.'), 'admin/store/products/orphans');
}
else {
$description .= ' ' . l(t('Add terms for the products to inhabit.'), 'admin/content/taxonomy/' . $catalog->vid . '/add/term');
}
$statuses[] = array(
'status' => 'warning',
'title' => t('Unlisted products'),
'desc' => $description,
);
}
}
else {
$statuses[] = array(
'status' => 'error',
'title' => t('Catalog vocabulary'),
'desc' => t('No vocabulary has been recognized as the Ubercart catalog. Choose one on <a href="!admin_catalog">this page</a> or click <a href="!admin_vocab">here</a> to create one first.', array(
'!admin_catalog' => url('admin/store/settings/catalog'),
'!admin_vocab' => url('admin/content/taxonomy'),
)),
);
}
return $statuses;
}