[Skip to main content](#vessel-content)

#   how to show price in search results

##

- **[kostia\_lev](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile")**
- [![kostia&#95;lev's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile") Topic Author
- [ Offline](/forum/user/15066-kostia-lev)

Less More

- Posts: 15
- Thank you received: 1
-
-
-

13 years 7 months ago -  13 years 7 months ago [\#98954](#98954) by [kostia\_lev](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile")  *[how to show price in search results](/forum/4-how-to/80377-how-to-show-price-in-search-results#98954 "Hello! I would like to make the view of search results containing price. Is it possible to use product/listing&#95;price.php for this like in listing&#95;table.php:  setLayout('listing&#95;price'); echo $this-&gt;loadTemplate(); ?&gt;  I would like to use product/listing&#95;price.php template for this. How can I create object productviewproduct in &#92;components&#92;com&#95;search&#92;views&#92;search&#92;tmpl&#92;default&#95;results.php and to display price with setLayout metod using listing&#95;price template? I know I can take all product info in /plugins/search/hikashop&#95;products/hikasohop&#95;products.php but can't figure it out how to take price including discount.  Thank you for the help!")* was created by *[kostia\_lev](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile")*

Hello!
I would like to make the view of search results containing price.
Is it possible to use product/listing_price.php for this like in listing_table.php:
&lt;td class="hikashop_product_price_row"&gt;
&lt;?php
$this-&gt;setLayout('listing_price');
echo $this-&gt;loadTemplate();
?&gt;
&lt;/td&gt;
I would like to use product/listing_price.php template for this.
How can I create object productviewproduct in \components\com_search\views\search\tmpl\default_results.php and to display price with setLayout metod using listing_price template?
I know I can take all product info in /plugins/search/hikashop_products/hikasohop_products.php but can't figure it out how to take price including discount.

Thank you for the help!

Last edit: 13 years 7 months ago by [kostia\_lev](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgwMzc3LWhvdy10by1zaG93LXByaWNlLWluLXNlYXJjaC1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86576
- Thank you received: 14320
-
-

13 years 7 months ago [\#99069](#99069) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[how to show price in search results](/forum/4-how-to/80377-how-to-show-price-in-search-results#99069 "Hello! I would like to make the view of search results containing price. Is it possible to use product/listing&#95;price.php for this like in listing&#95;table.php:  setLayout('listing&#95;price'); echo $this-&gt;loadTemplate(); ?&gt;  I would like to use product/listing&#95;price.php template for this. How can I create object productviewproduct in &#92;components&#92;com&#95;search&#92;views&#92;search&#92;tmpl&#92;default&#95;results.php and to display price with setLayout metod using listing&#95;price template? I know I can take all product info in /plugins/search/hikashop&#95;products/hikasohop&#95;products.php but can't figure it out how to take price including discount.  Thank you for the help!")*

Hi,

Displaying the price is more complex than that as you first need to retrieve it from the database, make the necessary calculations, format it and only then display it.
In the listing_table, all that is hidden "under the hood". But since the joomla search results page cannot display the prices, they are not loaded by the search plugin so you need to add the code for that yourself. Needless to say that is it more than just two lines of code to add...

The simplest would be to actually not use the joomla search module but instead create a HikaShop text filter and use the HikaShop filter module to actually use a products listing menu for the results of the search:
[ www.hikashop.com/en/support/documentatio...-filter-listing.html](http://www.hikashop.com/en/support/documentation/101-hikashop-filter-listing.html)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgwMzc3LWhvdy10by1zaG93LXByaWNlLWluLXNlYXJjaC1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[kostia\_lev](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile")**
- [![kostia&#95;lev's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile") Topic Author
- [ Offline](/forum/user/15066-kostia-lev)

Less More

- Posts: 15
- Thank you received: 1
-
-
-

13 years 7 months ago [\#99202](#99202) by [kostia\_lev](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile")  Replied by *[kostia\_lev](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile")* on topic *[how to show price in search results](/forum/4-how-to/80377-how-to-show-price-in-search-results#99202 "Hello! I would like to make the view of search results containing price. Is it possible to use product/listing&#95;price.php for this like in listing&#95;table.php:  setLayout('listing&#95;price'); echo $this-&gt;loadTemplate(); ?&gt;  I would like to use product/listing&#95;price.php template for this. How can I create object productviewproduct in &#92;components&#92;com&#95;search&#92;views&#92;search&#92;tmpl&#92;default&#95;results.php and to display price with setLayout metod using listing&#95;price template? I know I can take all product info in /plugins/search/hikashop&#95;products/hikasohop&#95;products.php but can't figure it out how to take price including discount.  Thank you for the help!")*

Thanx, but it is impossible to just use text filter for me.
I see that listing_price.php template just receives $price object containing all prices.

Can you please point me to where this object which contains all prices is created so that I have an example.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgwMzc3LWhvdy10by1zaG93LXByaWNlLWluLXNlYXJjaC1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86576
- Thank you received: 14320
-
-

13 years 7 months ago [\#99211](#99211) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[how to show price in search results](/forum/4-how-to/80377-how-to-show-price-in-search-results#99211 "Hello! I would like to make the view of search results containing price. Is it possible to use product/listing&#95;price.php for this like in listing&#95;table.php:  setLayout('listing&#95;price'); echo $this-&gt;loadTemplate(); ?&gt;  I would like to use product/listing&#95;price.php template for this. How can I create object productviewproduct in &#92;components&#92;com&#95;search&#92;views&#92;search&#92;tmpl&#92;default&#95;results.php and to display price with setLayout metod using listing&#95;price template? I know I can take all product info in /plugins/search/hikashop&#95;products/hikasohop&#95;products.php but can't figure it out how to take price including discount.  Thank you for the help!")*

It is done in the components/com_hikashop/views/product/view.html.php file with the call to the getPrices function.

The following user(s) said Thank You: [kostia\_lev](/forum/user/15066-kostia-lev "View kostia&#95;lev's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgwMzc3LWhvdy10by1zaG93LXByaWNlLWluLXNlYXJjaC1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mSnus](/forum/user/58186-msnus "View mSnus's Profile")**
- [![mSnus's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/58186-msnus "View mSnus's Profile")
- [ Offline](/forum/user/58186-msnus)

Less More

- Posts: 10
- Thank you received: 1
-
-

5 years 8 months ago [\#330623](#330623) by [mSnus](/forum/user/58186-msnus "View mSnus's Profile")  Replied by *[mSnus](/forum/user/58186-msnus "View mSnus's Profile")* on topic *[how to show price in search results](/forum/4-how-to/80377-how-to-show-price-in-search-results#330623 "Hello! I would like to make the view of search results containing price. Is it possible to use product/listing&#95;price.php for this like in listing&#95;table.php:  setLayout('listing&#95;price'); echo $this-&gt;loadTemplate(); ?&gt;  I would like to use product/listing&#95;price.php template for this. How can I create object productviewproduct in &#92;components&#92;com&#95;search&#92;views&#92;search&#92;tmpl&#92;default&#95;results.php and to display price with setLayout metod using listing&#95;price template? I know I can take all product info in /plugins/search/hikashop&#95;products/hikasohop&#95;products.php but can't figure it out how to take price including discount.  Thank you for the help!")*

For someone who still needs this ![;-)](/media/kunena/emoticons/24.png ";-)")

Solved the same question with a dirty hack in **components/com\_finder/models/search.php**:
Code:

/** * Add prices to search results - mSnus * Joomla 3.9.25 * components/com_finder/models/search.php * around line 118 */ // Load the results from the database. $db-&gt;setQuery($query); $rows = $db-&gt;loadObjectList('link_id'); // Set up our results container. $results = $items; $arrHikaIds = []; // Convert the rows to result objects. foreach ($rows as $rk =&gt; $row) { // Build the result object. $result = unserialize($row-&gt;object); $result-&gt;weight = $results[$rk]; $result-&gt;link_id = $rk; $arrHikaIds[] = $result-&gt;__get('id'); // Add the result back to the stack. $results[$rk] = $result; } $query2 = $db-&gt;getQuery(true) -&gt;select($db-&gt;quoteName('product_id') . ', ' . $db-&gt;quoteName('product_sort_price')) -&gt;from($db-&gt;quoteName('#__hikashop_product')) -&gt;where($db-&gt;quoteName('product_id') . ' IN (' . implode(',', $arrHikaIds) . ')'); $db-&gt;setQuery($query2); $rows2 = $db-&gt;loadAssocList(); $idToPrice = []; foreach ($rows2 as $rk =&gt; $row) { $idToPrice[$row['product_id']] = $row['product_sort_price']; } foreach ($results as $rk =&gt; &amp;$result) { $oid = $results[$rk]-&gt;__get('id'); $results[$rk]-&gt;__set('price', $idToPrice[$oid]); } /** * -- end adding price to search results */

After this modification you will be able to use **$this-&gt;result-&gt;price**
in your **templates/&lt;...your template name...&gt;/html/com\_finder/search/default\_result.php** , for example:
Code:

&lt;h5&gt;USD &lt;?php echo(intval($this-&gt;result-&gt;price)); ?&gt; &lt;/h5&gt;

Maybe someone could improve the answer with moving my function to some SmartSearch plugin, but my way will do.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgwMzc3LWhvdy10by1zaG93LXByaWNlLWluLXNlYXJjaC1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.054 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
