Skip to main content

Exclude product from search

More
11 years 11 months ago #176317 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.

Please Log in or Create an account to join the conversation.

More
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.

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #176430 by gielhier
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

Please Log in or Create an account to join the conversation.

More
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:
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.

More
11 years 11 months ago #176604 by gielhier
Hello,

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.

More
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.

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #176731 by gielhier
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?

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #176733 by Xavier
Replied by Xavier on topic Exclude product from search
Hi,

Ok so please add:
Code:
unset($rows['YOUR_ID']);
Just before:
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.

More
11 years 11 months ago #176995 by gielhier
Thank you, this works! Thanks a lot!!!

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago #187238 by PeterChain
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).

Please Log in or Create an account to join the conversation.

More
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:
Code:
foreach($rows as $k => $row){ if(in_array($row->product_category_id,array('XX','YY'))){ unset($rows[$k]); } }
Just before:
Code:
return $rows;
Replace "XX" and "YY" by the ids of the undesired categories.

Please Log in or Create an account to join the conversation.

Time to create page: 0.209 seconds
Powered by Kunena Forum