Forum
No search results - Perch Shop
Hello,
I am having trouble with the search function for my products. On my website I have a blog page with a search function that gives results only from the blog page, this is working fine. Now I want a search function on my product page, but it is giving me no results.
Search form HTML:
<perch:form class="form-inline" id="search" method="get" action="/producten/zoekresultaten">
<div class="form-group has-feedback product-search" style="margin-top: 22px">
<perch:input placeholder="Zoeken..." name="search" type="search" name="q" id="q" class="form-control" />
</div>
</perch:form>
Search form on my page:
<?php perch_search_form(array(
'template'=>'search-form-product.html',
'from-path'=>'/producten/',
));
?>
Search results page:
<?php
$query = perch_get('q');
perch_content_search($query, array(
'count'=>10,
'apps' => ['PerchShop'],
));
?>
Debug after searching and getting no results:
Debug Message - Perch 3.0.14
[38] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
[1] SELECT * FROM perch3_pages WHERE pagePath='/producten/zoekresultaten.php' LIMIT 1
[1] SELECT * FROM perch3_shop_cart WHERE cartID=7
[1] SELECT * FROM perch3_shop_cart WHERE cartID=7
Using template: \templates\search\search-form-product.html
Using template: \templates\search\search-form-product.html
Search term: wijn
[nil] SELECT SQL_CALC_FOUND_ROWS DISTINCT 'PerchContent_SearchHandler' AS source, '' AS score, '' AS col1, '' AS col2, '' AS col3, '' AS col4, '' AS col5, '' AS col6, '' AS col7, '' AS col8 FROM perch3_content_regions WHERE 1=0 UNION SELECT 'PerchShop_SearchHandler' AS source, MATCH(s.searchBody) AGAINST('wijn') AS score, p.title, p.productSlug, p.productDynamicFields, p.productTemplate, productID, "", "", "" FROM perch3_shop_search s, perch3_shop_products p WHERE p.productDeleted IS NULL AND p.productID=s.itemKey AND s.itemType='product' AND MATCH(s.searchBody) AGAINST('wijn') AND p.productID IN ( SELECT itemID FROM perch3_shop_index WHERE itemKey='productID' AND itemID=p.productID AND indexKey='status' AND indexValue=1 ) ORDER BY score DESC LIMIT 0, 10
[nil] SELECT SQL_CALC_FOUND_ROWS DISTINCT 'PerchContent_SearchHandler' AS source, '' AS score, '' AS col1, '' AS col2, '' AS col3, '' AS col4, '' AS col5, '' AS col6, '' AS col7, '' AS col8 FROM perch3_content_regions WHERE 1=0 UNION SELECT 'PerchShop_SearchHandler' AS source, p.stock_level AS score, p.title, p.productSlug, p.productDynamicFields, p.productTemplate, p.productID, "", "", "" FROM perch3_shop_search s, perch3_shop_products p WHERE p.productDeleted IS NULL AND p.productID=s.itemKey AND s.itemType='product' AND ( concat(" ", s.searchBody, " ") REGEXP '[[:<:]]wijn[[:>:]]' ) AND p.productID IN ( SELECT itemID FROM perch3_shop_index WHERE itemKey='productID' AND itemID=p.productID AND indexKey='status' AND indexValue=1 ) ORDER BY score ASC LIMIT 0, 10
[0] SELECT FOUND_ROWS() AS `count`
Using template: \templates\search\search-result.html
I have products in my shop.
How many of them would you expect to match a search for "wijn"? Are they all wines?
Well, I only added 3 products, of which one contains the word 'wijn'. I tried alot of different words, but it is not giving me results.
You'll need a lot more content before search starts giving reasonable results. 3 items isn't going to work.
So how could I test if it is working? Searching in blog gives me results, and I only have 3 test blog posts. Is it different for products?
Well it’s not working. It should start working once you’ve got a few dozen products in there.
Ok, I will give it a try. Thanks Drew