Вот код поискового мамбота, теперь может будет проще подсказать.
<?php
defined( '_VALID_MOS' ) or die( 'Прямой доступ запрещен.' );
$_MAMBOTS->registerFunction( 'onSearch', 'botSearchVM' );
function botSearchVM( $text, $phrase='', $ordering='' ) {
global $database;
$text = trim( $text );
if ($text == '') {
return array();
}
$wheres = array();
switch ($phrase) {
case 'exact':
$wheres2 = array();
$wheres2[] = "LOWER(product_name) LIKE '%$text%'";
$wheres2[] = "LOWER(product_sku) LIKE '%$text%'";
$wheres2[] = "LOWER(product_desc) LIKE '%$text%'";
$wheres2[] = "LOWER(product_s_desc) LIKE '%$text%'";
$wheres2[] = "LOWER(product_url) LIKE '%$text%'";
$where = '(' . implode( ') OR (', $wheres2 ) . ')';
break;
case 'all':
case 'any':
default:
$words = explode( ' ', $text );
$wheres = array();
foreach ($words as $word) {
$wheres2 = array();
$wheres2[] = "LOWER(product_name) LIKE '%$text%'";
$wheres2[] = "LOWER(product_sku) LIKE '%$text%'";
$wheres2[] = "LOWER(product_desc) LIKE '%$text%'";
$wheres2[] = "LOWER(product_s_desc) LIKE '%$text%'";
$wheres2[] = "LOWER(product_url) LIKE '%$text%'";
$wheres[] = implode( ' OR ', $wheres2 );
}
$where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')';
break;
}
switch ($ordering) {
case 'newest':
default:
$order = '#__vm_product.cdate DESC';
break;
case 'oldest':
$order = '#__vm_product.cdate ASC';
break;
case 'popular':
$order = '#__vm_product.product_name ASC';
break;
case 'alpha':
$order = '#__vm_product.product_name ASC';
break;
case 'category':
$order = '#__vm_category.category_name ASC';
break;
}
$database->setQuery( " SELECT id, name FROM `#__menu` WHERE link LIKE '%com_virtuemart%' AND published=1 AND access=0");
$database->loadObject( $Item );
$ItemName = !empty( $Item->name ) ? $Item->name : "Shop";
$Itemid = !empty( $Item->id ) ? $Item->id : "1";
$query = "SELECT product_name as title,"
. "\n FROM_UNIXTIME( #__vm_product.cdate, '%Y-%m-%d %H:%i:%s' ) AS created,"
. "\n product_s_desc AS text,"
. "\n CONCAT('$ItemName/',#__vm_category.category_name) as section,"
. "\n CONCAT('index.php?option=com_virtuemart&page=shop.product_details&flypage=',#__vm_category.category_flypage,'&category_id=',#__vm_category.category_id,'&product_id=', #__vm_product.product_id, '&Itemid=".$Itemid."' ) as href,"
. "\n '2' as browsernav"
. "\n FROM #__vm_product"
. "\n LEFT JOIN `#__vm_product_category_xref` ON `#__vm_product_category_xref`.`product_id` = `#__vm_product`.`product_id`"
. "\n LEFT JOIN `#__vm_category` ON `#__vm_product_category_xref`.`category_id` = `#__vm_category`.`category_id`"
. "\n WHERE $where"
. "\n AND (product_parent_id='' OR product_parent_id='0')"
. "\n AND product_publish='y'"
. "\n ORDER BY $order" ;
$database->setQuery( $query );
$row = $database->loadObjectList();
return $row;
}
?>