Menu Content

Podpora

> Diskusní fóra, FAQs & placená podpora
Welcome, Guest
Username Password: Remember me

How to modify product search ?
(1 viewing) (1) Guest
Support forum for customers who have purchased this product. Archive only, no new post can be added.

NOTE: This category has been locked. If you have purchased paid version, please, use our Support Ticket system instead. If you are using free edition, please see the Community Support section.
  • Page:
  • 1
  • 2

TOPIC: How to modify product search ?

How to modify product search ? 9 years, 10 months ago #44903

How to modify product search to find proctucs with a special colunm entry ?
The topic has been locked.

Re: How to modify product search ? 9 years, 10 months ago #44925

  • pama
  • OFFLINE
  • Posts: 489
Hello. What column do you want to use?

product search is defined in administrator/components/com_vminvoice/helpers/getter.php
in function
getAjaxProductList

Currently there is searched by product name (all languages) and SKU.
ARTIO Support Team
Last Edit: 9 years, 10 months ago by pama.
The topic has been locked.

Re: How to modify product search ? 9 years, 10 months ago #44926

In my table the colunms names are : product_barcode and product_isbn
varchan 200

thanks
The topic has been locked.

Re: How to modify product search ? 9 years, 10 months ago #44927

  • pama
  • OFFLINE
  • Posts: 489
You can put there

instead

WHERE '.implode(' OR ', $wheres).' OR p.`product_sku` LIKE ' . $db->Quote('%'.$filter.'%'),0,50);

put

WHERE '.implode(' OR ', $wheres).' OR p.`product_sku` LIKE ' . $db->Quote('%'.$filter.'%').' OR p.`product_barcode` =' . $db->Quote($filter).' OR p.`product_isbn` =' . $db->Quote($filter). ,0,50);

If you put database index on those two fields (e.g. by phpmyadmin), search will be faster.
ARTIO Support Team
Last Edit: 9 years, 10 months ago by pama.
The topic has been locked.

Re: How to modify product search ? 9 years, 10 months ago #44928

White page on the composant with this code :

//join all language tables, because we search in all languages and we need at least one translation
$joins = $wheres = $selects = array();
foreach (self::getVm2LanguageTable('#__virtuemart_products', -1) as $o => $tableName){
$selects[] = '`'.$tableName.'`.product_name AS product_name_'.substr($tableName, -5);
$joins[] = 'LEFT JOIN `'.$tableName.'` ON (p.virtuemart_product_id = `'.$tableName.'`.virtuemart_product_id)';
$wheres[] = '`'.$tableName.'`.`product_name` LIKE '.$db->Quote('%' . $filter . '%').'';
}

$db->setQuery('SELECT p.`virtuemart_product_id` AS `id`, p.`product_sku`,
p.product_in_stock, p.product_ordered, '.implode(', ', $selects).'
FROM `#__virtuemart_products` AS p '.implode(' ', $joins).'
WHERE '.implode(' OR ', $wheres).' OR p.`product_sku` LIKE ' . $db->Quote('%'.$filter.'%').' OR p.`product_barcode` LIKE ' .
$db->Quote($filter).' OR p.`product_isbn` LIKE ' . $db->Quote($filter). ,0,50);
}
else
$db->setQuery('SELECT `product_id` AS `id`,`product_name`, `product_sku`, product_in_stock
FROM `#__vm_product`
WHERE `product_name` LIKE ' . $db->Quote('%' . $filter . '%').' OR `product_sku` LIKE ' . $db->Quote('%' . $filter . '%'),0,50);

$res = $db->loadObjectList();
if (COM_VMINVOICE_ISVM2)
self::pickTranslation($res, 'product_name', $lang); //pick proper translation of product name

foreach ($res as $product)


Thanks
Last Edit: 9 years, 10 months ago by gael30.
The topic has been locked.

Re: How to modify product search ? 9 years, 10 months ago #44930

  • pama
  • OFFLINE
  • Posts: 489
Ah. Sorry. One dot on end.

It should be

WHERE '.implode(' OR ', $wheres).' OR p.`product_sku` LIKE ' . $db->Quote('%'.$filter.'%').' OR p.`product_barcode` = ' . $db->Quote($filter).' OR p.`product_isbn` = ' . $db->Quote($filter), 0, 50);
ARTIO Support Team
The topic has been locked.
  • Page:
  • 1
  • 2
Přihlášení uživatele Prázdný