- Posts: 90
- Thank you received: 2
Exclude product from search
11 years 11 months ago #176317
by gielhier
Exclude product from search was created by gielhier
-- HikaShop version -- : 2.3.3
Hello,
I want to exclude a product from the product-search.
Can yoiu please tell me how to do this?
Thanks in advance.
Hello,
I want to exclude a product from the product-search.
Can yoiu please tell me how to do this?
Thanks in advance.
Please Log in or Create an account to join the conversation.
11 years 11 months ago #176319
by Xavier
Replied by Xavier on topic Exclude product from search
Hi,
If it's only one product in a category where there is other products, so you will have to edit the hikashop search plugin.
PHP knowledges will be required.
If this product is in another category, you can unpublish that category.
If it's only one product in a category where there is other products, so you will have to edit the hikashop search plugin.
PHP knowledges will be required.
If this product is in another category, you can unpublish that category.
Please Log in or Create an account to join the conversation.
11 years 11 months ago #176430
by gielhier
Replied by gielhier on topic Exclude product from search
Hello,
it's just one product. Can you please tell how to exclude it in the search plugin?
What file do I need to edit?
Thanks in advance
it's just one product. Can you please tell how to exclude it in the search plugin?
What file do I need to edit?
Thanks in advance
Please Log in or Create an account to join the conversation.
11 years 11 months ago #176451
by Xavier
Replied by Xavier on topic Exclude product from search
Hi,
You have to edit the file:
"plugins/search/hikashop_products/hikashop_products.php"
And add the code:
After:
You have to edit the file:
"plugins/search/hikashop_products/hikashop_products.php"
And add the code:
Code:
if($rows[$k]->product_id == 'YOUR_PRODUCT_ID')
unset($rows[$k]);
After:
Code:
if(empty($row->product_canonical)){
$rows[$k]->href = 'index.php?option=com_hikashop&ctrl=product&task=show&name='.$row->alias.'&cid='.$row->id.$Itemid.$parent;
}else{
$rows[$k]->href = $row->product_canonical;
}
$rows[$k]->section = JText::_( 'PRODUCT' );
Please Log in or Create an account to join the conversation.
11 years 11 months ago #176604
by gielhier
Replied by gielhier on topic Exclude product from search
Hello,
thanks for the help, but I can't find that phrase in hikashop_products.php.
The only lines that looks like it, are:
But if I add your code after that, it doesn't work...
Please help!
thanks for the help, but I can't find that phrase in hikashop_products.php.
The only lines that looks like it, are:
Code:
$rows[$k]->href = 'index.php?option=com_hikashop&ctrl=product&task=show&name='.$row->alias.'&cid='.$row->id.$Itemid.$parent;
$rows[$k]->section = JText::_( 'PRODUCT' );
But if I add your code after that, it doesn't work...
Please help!
Please Log in or Create an account to join the conversation.
11 years 11 months ago #176613
by Xavier
Replied by Xavier on topic Exclude product from search
Hi,
That's potentially because there is a fatal error, you can set the Joomla error reporting level to "maximum" temporarily in order to see the error and correct it.
That's potentially because there is a fatal error, you can set the Joomla error reporting level to "maximum" temporarily in order to see the error and correct it.
Please Log in or Create an account to join the conversation.
11 years 11 months ago #176731
by gielhier
Replied by gielhier on topic Exclude product from search
Hi,
I don't get an error, the product I want to hide, doesn't hide and keeps visible in the search-results.
What am I doing wrong?
I don't get an error, the product I want to hide, doesn't hide and keeps visible in the search-results.
What am I doing wrong?
Please Log in or Create an account to join the conversation.
11 years 11 months ago #176733
by Xavier
Replied by Xavier on topic Exclude product from search
Hi,
Ok so please add:
Just before:
I just tested this one, and it's working fine
Ok so please add:
Code:
unset($rows['YOUR_ID']);
Code:
return $rows;
I just tested this one, and it's working fine
The following user(s) said Thank You: gielhier
Please Log in or Create an account to join the conversation.
11 years 11 months ago #176995
by gielhier
Replied by gielhier on topic Exclude product from search
Thank you, this works! Thanks a lot!!!
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 640
- Thank you received: 16
11 years 8 months ago #187238
by PeterChain
Replied by PeterChain on topic Exclude product from search
Could you give advise on how to exclude some categories form search?
Either by simply puting the category ID or by checking a custom field in the categories like (category_search_disabled).
Either by simply puting the category ID or by checking a custom field in the categories like (category_search_disabled).
Please Log in or Create an account to join the conversation.
11 years 8 months ago #187269
by Xavier
Replied by Xavier on topic Exclude product from search
Hi,
You can create a menu which is not listing the products of these categories and use it in the settings of the hikashop product search plugin. It will potentially require a little management in the categories tree to have something like:
- Main category
-- Sub category A
-- Sub category B
- Not wanted in search
And create a menu listing the product of the "Main category" and it sub categories, then use this id in the plugin settings.
Or you can use code like:
Just before:
Replace "XX" and "YY" by the ids of the undesired categories.
You can create a menu which is not listing the products of these categories and use it in the settings of the hikashop product search plugin. It will potentially require a little management in the categories tree to have something like:
- Main category
-- Sub category A
-- Sub category B
- Not wanted in search
And create a menu listing the product of the "Main category" and it sub categories, then use this id in the plugin settings.
Or you can use code like:
Code:
foreach($rows as $k => $row){
if(in_array($row->product_category_id,array('XX','YY'))){
unset($rows[$k]);
}
}
Code:
return $rows;
Please Log in or Create an account to join the conversation.
Time to create page: 0.209 seconds