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

#   Product Database Query - Narrow the results

##

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

Less More

- Posts: 38
- Thank you received: 0
-
-

15 years 3 months ago [\#21991](#21991) by [mrdan](/forum/user/3459-mrdan "View mrdan's Profile")  *[Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#21991 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")* was created by *[mrdan](/forum/user/3459-mrdan "View mrdan's Profile")*

In the file / view product / listing_div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.

I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = "abc")?:
foreach($this-&gt;rows as $row){
if (
?&gt;
&lt;div class="hikashop_product" style="width:&lt;?php echo $width;?&gt;%;"&gt;
&lt;div class="hikashop_container"&gt;
&lt;div class="hikashop_subcontainer"&gt;
&lt;?php
$this-&gt;row =&amp; $row;
$this-&gt;setLayout('listing_'.$this-&gt;params-&gt;get('div_item_layout_type'));
echo $this-&gt;loadTemplate();
?&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;?php if($current_column&gt;=$columns){ ?&gt;
&lt;div style="clear:both"&gt;&lt;/div&gt;
&lt;?php
$current_column=0;
}
$current_column++;
}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzIxOTkxLXByb2R1Y3QtZGF0YWJhc2UtcXVlcnktbmFycm93LXRoZS1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

15 years 3 months ago -  15 years 3 months ago [\#22001](#22001) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22001 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

You can't do that in the view. You need to create a hikashop plugin and implement the method onBeforeProductListingLoad :

[ www.hikashop.com/support/documentation/6...ntation.html#content](http://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#content)

That way, you can dynamically add filters to the products loading query.

Last edit: 15 years 3 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

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

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

Less More

- Posts: 38
- Thank you received: 0
-
-

15 years 3 months ago [\#22005](#22005) by [mrdan](/forum/user/3459-mrdan "View mrdan's Profile")  Replied by *[mrdan](/forum/user/3459-mrdan "View mrdan's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22005 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

Thanks for your quick response and help. I give it a whirl.

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

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

Less More

- Posts: 38
- Thank you received: 0
-
-

15 years 2 months ago [\#22061](#22061) by [mrdan](/forum/user/3459-mrdan "View mrdan's Profile")  Replied by *[mrdan](/forum/user/3459-mrdan "View mrdan's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22061 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

I've added the plugin, but the filter is ignored on the front end and the back end throws an error:

Warning: Invalid argument supplied for foreach() in /home/.../administrator/components/com_hikashop/views/dashboard/view.html.php on line 423

I don't think I'm constructing the filter value properly. Can you advise?

Here is plugin:
&lt;?php
defined('_JEXEC') or die('Restricted access');
?&gt;
&lt;?php

class plgHikashopCategoryFilters extends JPlugin{

function plgHikashopCategoryFilters(&amp;$subject, $config){
parent::__construct($subject, $config);
}

function onBeforeCategoryListingLoad(&amp;$filters){

$ageval = $_POST;
$locval = $_POST;
$typeval = $_POST;
$filters[0] = "(age = '$ageval') AND (type = '$typeval') AND (location = '$locval')";
//echo $filters[0];
return true;
}
}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzIxOTkxLXByb2R1Y3QtZGF0YWJhc2UtcXVlcnktbmFycm93LXRoZS1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

15 years 2 months ago -  15 years 2 months ago [\#22063](#22063) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22063 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

That's indeed not how you should do it.
First you need to filter the variables from the POST. Otherwise, your website could be easily hacked. Second, you should not change the filters already in the $filters variable but ADD new filters.

Instead of:
$filters[0] = "(age = '$ageval') AND (type = '$typeval') AND (location = '$locval')";
you should do:
$db =&amp; JFactory::getDBO();
$filters[] = "age = ".$db-&gt;Quote($ageval);
$filters[] = "type = ".$db-&gt;Quote($typeval);
$filters[] = "location = ".$db-&gt;Quote($locval);

Last edit: 15 years 2 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile"). Reason: quotes issue corrected

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

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

Less More

- Posts: 38
- Thank you received: 0
-
-

15 years 2 months ago [\#22066](#22066) by [mrdan](/forum/user/3459-mrdan "View mrdan's Profile")  Replied by *[mrdan](/forum/user/3459-mrdan "View mrdan's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22066 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

Thanks for the help.

I changed it to this but it still does not seem to have any effect on front end and still get same warning on back end. These are custom fields defined for the product. Any ideas? :

&lt;?php
defined('_JEXEC') or die('Restricted access');
?&gt;
&lt;?php

class plgHikashopCategoryFilters extends JPlugin{

function plgHikashopCategoryFilters(&amp;$subject, $config){
parent::__construct($subject, $config);
}

function onBeforeCategoryListingLoad(&amp;$filters){

if(isset($_POST)) { $age = stripslashes($_POST); } else { $age = "All";};
if(isset($_POST)) { $location = stripslashes($_POST); } else { $location = "All";};
if(isset($_POST)) { $type = stripslashes($_POST); } else { $type = "All";};

$db =&amp; JFactory::getDBO();
$filters[] = "age = '".$db-&gt;Quote($age)."'";
$filters[] = "type = '".$db-&gt;Quote($type)."'";
$filters[] = "location = '".$db-&gt;Quote($location)."'";
echo $filters[0];
echo $filters[1];
echo $filters[2];
echo $filters[3];
echo $filters[4];
return true;
}
}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzIxOTkxLXByb2R1Y3QtZGF0YWJhc2UtcXVlcnktbmFycm93LXRoZS1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

15 years 2 months ago [\#22076](#22076) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22076 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

That seems fine. Is your plugin's xml file correct ? Did you publish the plugin in joomla ? (the warning on the back end is not related. Could you copy/paste here the line 423 of the file administrator/components/com_hikashop/views/dashboard/view.html.php ? )

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

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

Less More

- Posts: 38
- Thank you received: 0
-
-

15 years 2 months ago -  15 years 2 months ago [\#22083](#22083) by [mrdan](/forum/user/3459-mrdan "View mrdan's Profile")  Replied by *[mrdan](/forum/user/3459-mrdan "View mrdan's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22083 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

HI,

Here is message in back end when clicking on Components Hikashop (message goes away when I disable the plugin):

a.category_parent_id = 4age = ''All''type = ''All''location = ''All''trans =
Warning: Invalid argument supplied for foreach() in /administrator/components/com_hikashop/views/dashboard/view.html.php on line 423
Warning: Invalid argument supplied for foreach() in /administrator/components/com_hikashop/views/dashboard/view.html.php on line 423
Warning: Invalid argument supplied for foreach() in /administrator/components/com_hikashop/views/dashboard/view.html.php on line 423
Warning: Invalid argument supplied for foreach() in /administrator/components/com_hikashop/views/dashboard/view.html.php on line 423
Warning: Invalid argument supplied for foreach() in /administrator/components/com_hikashop/views/dashboard/view.html.php on line 423
Warning: Invalid argument supplied for foreach() in /administrator/components/com_hikashop/views/dashboard/view.html.php on line 423
a.category_parent_id = 4age = ''All''type = ''All''location = ''All''trans =

Here is XML file, maybe I'm missing something:

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!DOCTYPE install SYSTEM "[ dev.joomla.org/xml/1.5/plugin-install.dtd](http://dev.joomla.org/xml/1.5/plugin-install.dtd)"&gt;
&lt;install type="plugin" version="1.5" method="upgrade" group="hikashop"&gt;
&lt;name&gt;Hikashop Category Filters Plugin&lt;/name&gt;
&lt;creationDate&gt;July 2011&lt;/creationDate&gt;
&lt;version&gt;1.0.0&lt;/version&gt;
&lt;author&gt;Sullivan&lt;/author&gt;
&lt;authorEmail&gt;info@gophercreative.com&lt;/authorEmail&gt;
&lt;authorUrl&gt;[ www.gophercreative.com](http://www.gophercreative.com)&lt;/authorUrl&gt;
&lt;copyright&gt;Copyright (C) 2011&lt;/copyright&gt;
&lt;license&gt;[ www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html) GNU/GPL&lt;/license&gt;
&lt;description&gt;This plugin adds extra filters to category selection&lt;/description&gt;
&lt;files&gt;
&lt;filename plugin="categoryfilters"&gt;categoryfilters.php&lt;/filename&gt;
&lt;/files&gt;
&lt;params addpath="/components/com_hikashop/params"&gt;
&lt;/params&gt;
&lt;/install&gt;

Last edit: 15 years 2 months ago by [mrdan](/forum/user/3459-mrdan "View mrdan's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzIxOTkxLXByb2R1Y3QtZGF0YWJhc2UtcXVlcnktbmFycm93LXRoZS1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

15 years 2 months ago [\#22085](#22085) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22085 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

The problem might be the quotes.
Please try with :
$filters[] = "age = ".$db-&gt;Quote($ageval);
$filters[] = "type = ".$db-&gt;Quote($typeval);
$filters[] = "location = ".$db-&gt;Quote($locval);
instead of :
$filters[] = "age = '".$db-&gt;Quote($age)."'";
$filters[] = "type = '".$db-&gt;Quote($type)."'";
$filters[] = "location = '".$db-&gt;Quote($location)."'";

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

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

Less More

- Posts: 38
- Thank you received: 0
-
-

15 years 2 months ago [\#22087](#22087) by [mrdan](/forum/user/3459-mrdan "View mrdan's Profile")  Replied by *[mrdan](/forum/user/3459-mrdan "View mrdan's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22087 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

Same thing except now values displayed with echo command have single quotes around them instead of double quotes.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzIxOTkxLXByb2R1Y3QtZGF0YWJhc2UtcXVlcnktbmFycm93LXRoZS1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

15 years 2 months ago [\#22089](#22089) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22089 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

Wait, the function you're implementing is onBeforeCategoryListingLoad, but on the link you gave, I only see products, no categories... That's why it's not working. You should implement onBeforeProductListingLoad as I said in my first post.

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

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

Less More

- Posts: 38
- Thank you received: 0
-
-

15 years 2 months ago [\#22091](#22091) by [mrdan](/forum/user/3459-mrdan "View mrdan's Profile")  Replied by *[mrdan](/forum/user/3459-mrdan "View mrdan's Profile")* on topic *[Re: Product Database Query - Narrow the results](/forum/2-general-talk-about-hikashop/21991-product-database-query-narrow-the-results#22091 "In the file / view product / listing&#95;div, I wish to narrow the results of the category database query so that custom product fields are reflected in the query.  I want to modify the code that displays the products in a particular category (below). How can I narrow the products displayed based on a particular value of a custom product field (for instance, WHERE xyz = &quot;abc&quot;)?: foreach($this-&gt;rows as $row){ if ( ?&gt; div class=&quot;hikashop&#95;product&quot; style=&quot;width:%;&quot;&gt;   row =&amp; $row; $this-&gt;setLayout('listing&#95;'.$this-&gt;params-&gt;get('div&#95;item&#95;layout&#95;type')); echo $this-&gt;loadTemplate(); ?&gt;    =$columns){ ?&gt;  php $current&#95;column=0; } $current&#95;column++; }")*

Thanks very much for finding my mistake. Works great now!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzIxOTkxLXByb2R1Y3QtZGF0YWJhc2UtcXVlcnktbmFycm93LXRoZS1yZXN1bHRzP3RtcGw9bWFya2Rvd24=) 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: 1.591 seconds

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

[](#top)
