Forum
Search Products
Hi.
I've used search lots of times, but my first with products;
My form;
<perch:form id="search" method="get" action="/search">
<div class="clearfix">
<perch:label for="q"></perch:label>
<div class="col-xs-8 col-sm-8 no-padding">
<perch:input type="search" id="q" placeholder="search products" />
</div>
<div class="col-xs-4 col-sm-4 no-padding">
<perch:input type="submit" id="g" value="Search" />
</div>
</div>
</perch:form>
my results;
<perch:before>
<h1>Search results for “<perch:search id="search_key" />”</h1>
<perch:if exists="paging">
<p><perch:search id="total" /> results</p>
</perch:if>
<ul>
</perch:before>
<li class="<perch:search id="perch_item_odd" />">
<h2><a href="<perch:search id="result_url" />"><perch:search id="result_title" /></a></h2>
<perch:if exists="result_excerpt"><p class="excerpt">…<perch:search id="result_excerpt" encode="false" />…</p></perch:if>
<p><a href="<perch:search id="result_url" />">
<perch:if exists="result_pageNavText">
<perch:search id="result_pageNavText" />
<perch:else />
<perch:search id="result_url" />
</perch:if>
</a></p>
</li>
<div class="line-divider"></div>
<perch:after>
</ul>
<perch:if exists="paging">
<div class="paging">
Page <perch:search id="current_page" /> of <perch:search id="number_of_pages" />
<perch:if exists="not_first_page">
<a href="<perch:search id="prev_url" encode="false" />">Previous</a>
</perch:if>
<perch:if exists="not_last_page">
<a href="<perch:search id="next_url" encode="false" />">Next</a>
</perch:if>
</div>
</perch:if>
</perch:after>
<perch:noresults>
<perch:if exists="search_key">
<h1>Search results for “<perch:search id="search_key" />”</h1>
<perch:else />
<h1>Search</h1>
</perch:if>
<perch:if exists="search_key">
<p>Sorry, there are no results for “<perch:search id="search_key" />”.</p>
</perch:if>
</perch:noresults>
called by;
<?php $query = perch_get('q'); perch_content_search($query, array(
'count'=>12,
'from-path' => '/shop',
'apps' => ['PerchShop'],
));
?>
But I'm getting 12 results searching for a product all with shop/product/[slug:product]
as the url. Any I missing something??
Summary information
Perch Runway: 3.0.8, PHP: 5.4.45, MySQL: 5.5.54, with MySQLi
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.8), assets (3.0.8), categories (3.0.8), perch_blog (5.5.1), perch_shop_orders (1.2.2), perch_shop_products (1.2.2), perch_shop (1.2.2), perch_members (1.6.2)
App runtimes: <?php $apps_list = array( 'perch_members', 'perch_shop', 'perch_blog', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/fullfatwebsite/public_html/stotto/perch
PERCH_CORE: /home/fullfatwebsite/public_html/stotto/perch/core
PERCH_RESFILEPATH: /home/fullfatwebsite/public_html/stotto/perch/resources
Image manipulation: GD
PHP limits: Max upload 25M, Max POST 128M, Memory: 256M, Total max file upload: 25M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/fullfatwebsite/public_html/stotto
HTTP_HOST: stotto.fullfatwebsitedesign.co.uk
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
How many products do you have?
The client is still adding, at the moment 25.
So do you think that fewer products should match your query? I'm a bit lost.
I was expecting 1, but I get 9 and only the first contains the excerpt, the rest just the tile and link.
Below is a screenshot
Its more about the link though, being just being
shop/product/[slug:product]
rather than the urlAre the others the variants?
Ah, I see, yes, thats the variants in the search. In that case;
Can variants be removed from search results
How do I get the url, rather than just
shop/product/[slug:product]
Where is the
shop/product/[slug:product]
coming from?If think its taken it from the Product URL in settings
I think it should be something like
/shop/product/{productSlug}
Thanks. I've changed that, but the search now lists the urls as
/shop/product/
which just goes to an empty page, am I missing something to get the full urls for the search results?Ah, sorry, try
/shop/product/{slug}
Thanks. That's got it.
Anything I can do to exclude the variants from the search?
I don't think so - I'll have a look into it.