Jump to content

Custom search based on multiple tags


SauronZ

Recommended Posts

Hi all.

This is my first mod and my first post ;)

I'm trying to make a custom query in search engine for search a product based on multiple tags coincidence.

The query i run is this one:

SELECT p . * , pl.`description_short` , pl.`link_rewrite` , pl.`name` , tax.`rate` , i.`id_image` , il.`legend`, pt.*, t.'name' AS tagname 
FROM `ps_product` p
LEFT JOIN `ps_product_lang` pl ON ( p.`id_product` = pl.`id_product` 
AND pl.`id_lang` =3 ) 
LEFT OUTER JOIN `ps_image` i ON ( i.`id_product` = p.`id_product` 
AND i.`cover` =1 ) 
LEFT JOIN `ps_image_lang` il ON ( i.`id_image` = il.`id_image` 
AND il.`id_lang` =3 ) 
LEFT JOIN `ps_tax` tax ON p.`id_tax` = tax.`id_tax` 
LEFT JOIN `ps_product_tag` pt ON p.`id_product` = pt.`id_product` 
LEFT JOIN `ps_tag` t ON ( pt.`id_tag` = t.`id_tag` 
AND t.`id_lang` =3 ) 
WHERE (
t.`tagname ` LIKE 'P-60%'
AND t.`tagname ` LIKE '0-160%'
)
AND p.`active` =1
GROUP BY pt.`id_product` 
LIMIT 0 , 30



The problem i haave is that whith only one condition :

WHERE (
t.`tagname ` LIKE 'P-60%'
)



It works great and show the correct product.

But with two conditins there is no result.

WHERE (
t.`tagname ` LIKE 'P-60%'
AND t.`tagname ` LIKE '0-160%'
)




Any ideas could help me plz?

Thnx to all in advance!!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...