Exclude product from search

  • Posts: 90
  • Thank you received: 2
  • Hikashop Business
10 years 10 months ago #176317

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

  • Posts: 13201
  • Thank you received: 2322
10 years 10 months ago #176319

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.

  • Posts: 90
  • Thank you received: 2
  • Hikashop Business
10 years 10 months ago #176430

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.

  • Posts: 13201
  • Thank you received: 2322
10 years 10 months ago #176451

Hi,

You have to edit the file:
"plugins/search/hikashop_products/hikashop_products.php"

And add the code:

if($rows[$k]->product_id == 'YOUR_PRODUCT_ID')
	unset($rows[$k]);

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

  • Posts: 90
  • Thank you received: 2
  • Hikashop Business
10 years 10 months ago #176604

Hello,

thanks for the help, but I can't find that phrase in hikashop_products.php.

The only lines that looks like it, are:

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

  • Posts: 13201
  • Thank you received: 2322
10 years 10 months ago #176613

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.

  • Posts: 90
  • Thank you received: 2
  • Hikashop Business
10 years 10 months ago #176731

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.

  • Posts: 13201
  • Thank you received: 2322
10 years 10 months ago #176733

Hi,

Ok so please add:

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

  • Posts: 90
  • Thank you received: 2
  • Hikashop Business
10 years 10 months ago #176995

Thank you, this works! Thanks a lot!!!

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

  • Posts: 639
  • Thank you received: 16
  • Hikashop Business
10 years 7 months ago #187238

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.

  • Posts: 13201
  • Thank you received: 2322
10 years 7 months ago #187269

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:

foreach($rows as $k => $row){
  if(in_array($row->product_category_id,array('XX','YY'))){
    unset($rows[$k]);
  }
}
Just before:
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.088 seconds
Powered by Kunena Forum