In the standard component of the component Virtuemart there is a product display module (Displays Recommended products, Bestsellers, Random products or New items) there is filtering by category, but there is no filtering by manufacturer. To solve the problem, I used the output template (product.php), used the Footer textbox (text after the module). In this field I will write the name of the manufacturer or any other search criteria in the name bar (for children, sleds, bars). I prescribe such a condition in the cycle

if( stripos($product->product_name,$footerText) ) {} 

if the $ footerText Latin works fine, but if it is Cyrillic, then there will be no product hits. As I found out, my encoding is UTF-8. And the comparison on the occurrence of the substring in the string should pass. But no.

And the iconv function does not solve the problem. What is the problem?

    1 answer 1

    The problem was solved as follows:

    • the variable is converted to the proper encoding

       $footerText_iconv = mb_convert_encoding($footerText, "UTF-8", "HTML-ENTITIES"); $footerText_iconv = iconv("UTF-8","ISO-8859-1",$footerText_iconv); 
    • the condition was wrong, so right:

       if( stripos($product->product_name,$footerText_iconv) !== false ) 

    If you need to make a quick hack for the standard module Vidtuemart output of goods with a certain word in the product name (color, size, manufacturer's name). Then this solution will be useful.