Hi,
My VM2 search is died. I don't know why, it doesn't find any product. So I modified the Joomla's search component/module/plugin and rather use that.
this is from plugins/search/virtuemart/virtuemart.php
(the new parts are marked with red)
Quote// search product //TODO b.virtuemart_category_id>0 should be configurable
$text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
$query = "SELECT DISTINCT CONCAT( a.product_name ) AS title, m.mf_name AS gyarto, p.product_sku AS sku, a.virtuemart_product_id , b.virtuemart_category_id , a.product_s_desc AS text, b.category_name as section,
p.created_on as created, '2' AS browsernav
FROM `#__virtuemart_products_".VMLANG."` AS a
JOIN #__virtuemart_products as p using (`virtuemart_product_id`)
LEFT JOIN `#__virtuemart_product_manufacturers` as pm ON p.`virtuemart_product_id` = pm.`virtuemart_product_id`
LEFT JOIN `#__virtuemart_manufacturers_".VMLANG."` as m ON pm.`virtuemart_manufacturer_id` = m.`virtuemart_manufacturer_id`
LEFT JOIN `#__virtuemart_product_prices` as pp ON p.`virtuemart_product_id` = pp.`virtuemart_product_id`
LEFT JOIN `#__virtuemart_product_categories` AS xref ON xref.`virtuemart_product_id` = a.`virtuemart_product_id`
LEFT JOIN `#__virtuemart_categories_".VMLANG."` AS b ON b.`virtuemart_category_id` = xref.`virtuemart_category_id`"
. ' WHERE ' . $where . ' and p.published=1 and b.virtuemart_category_id>0 ' . $override . ' '
. ' ORDER BY ' . $order
;
I can order by prices, I can search in the discounted products only if want, I can display the SKU and Manufacturer name with $RESULT->gyarto / sku and I can search in the skus, but if I try to search in mf_name, it doesn't works. Its find nothing, even if I trying with an existing product name.
This is how I tried:
Quoteswitch ($phrase) {
case 'exact':
$text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'm.mf_name LIKE ' . $word;
$wheres2[] = 'p.product_sku LIKE ' . $text;
$wheres2[] = 'a.product_name LIKE ' . $text;
$wheres2[] = 'a.product_s_desc LIKE ' . $text;
$wheres2[] = 'a.product_desc LIKE ' . $text;
$wheres2[] = 'b.category_name LIKE ' . $text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'm.mf_name LIKE ' . $word;
$wheres2[] = 'p.product_sku LIKE ' . $word;
$wheres2[] = 'a.product_name LIKE ' . $word;
$wheres2[] = 'a.product_s_desc LIKE ' . $word;
$wheres2[] = 'a.product_desc LIKE ' . $word;
$wheres2[] = 'b.category_name LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
It works with the exact option only. Why doesn't it work with the others too?
Thanks,
Erik