Text filter on categories

  • Posts: 79
  • Thank you received: 3
9 years 8 months ago #195872

-- HikaShop version -- : Business: 2.4.0
-- Joomla version -- : 3.2.3
-- PHP version -- : 5.3.3

Hello.
Is there any way to do a filter on categories with a text field ?.
Let me explain myself, I have a book store and I use categories to set the book Authors in order to prevent repeat authors names and because we need set filters by author. We have more than 200 diferent authors and nothing but Text type is valid for us due to number of categories we have.

All what we need is a filter that applies like category search at categories section in the backend. Is it posible?




Regards

Attachments:
Last edit: 9 years 8 months ago by pljuarez.

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 8 months ago #195878

Hi,

Filters only works on products listings, not categories listings. So you won't be able to do that we a category filter.
What you can do however is to configure the HikaShop Categories search plugin via the Joomla plugins manager and enable the Joomla search module.
That will allow you to have a search on the categories on the frontend with a text box and you'll then be able to click on the categories found in order to display the products of the category.

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

  • Posts: 79
  • Thank you received: 3
9 years 8 months ago #195997

Hello, I configure HikaShop Categories search plugin (category_search.jpg), but where can I Ifind Joomla search module in order to enable it?

I look for it at my Joomla Modules and Hikashop Modules but I can't find it.

Regards

Attachments:

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 8 months ago #196002

You can find it in the Joomla modules manager.
If you don't see it, just click on the "new" button there and select the Joomla search module in order to create a new instance for it.

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

  • Posts: 79
  • Thank you received: 3
9 years 8 months ago #196127

Hello, Nicolas.

Correct me if I'm wrong, but your solution implies to use two independent searches one for products and one for categories (joomla search)?.

But what I need is a combined search (combined_search.jpg) in which a user can refine searches typing multiple search criteria.

I need to aply for authors a filter like:
select ... where category like '%...%' ...
instead of:
select ... where category = '...' ...
that it seems to use when you select a category in a drop down list.

Can I modify/generate some code to do this?

Regards

Attachments:

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 7 months ago #196200

Hi,

For sure you can modify the HikaShop core if you want to add your specific features but the best is still to add features using overrides/plugins so you will be able to update HikaShop and keep your plugins/overrides.
You can use a trigger like "onBeforeProductListingLoad"
www.hikashop.com/support/support/documen...reProductListingLoad

For the query you wrote ; it's a little more complicated than that because a product ca be in several categories.

The HikaShop queries are using the table "hikashop_product" and the table "hikashop_product_category" ; but we generally do not link to the table "hikashop_category" in order to minimize the table joins (and keep queries as fast as possible).
Because we generally filter on the category_id ; we do not need the table "hikashop_category".
So if you want to add your special filter on some category fields, you need to join an extra table and add your specific filters.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 79
  • Thank you received: 3
9 years 7 months ago #196232

Thank you Jerome, I try to do a pluging based on your explanation in order to do this, because for my client, author searches are critical

Regards.

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

  • Posts: 79
  • Thank you received: 3
9 years 7 months ago #198018

Hello Jerome.

When I tried to do a plugin based on your explanation I found several problems and I changed the approach to my problem.
Instead of doing a search plugin, I add a custom field to my product table in order to do a filter based in this custom field. Then, I developed a product plugin based on "onBeforeProductCreate" and "onBeforeProductUpdate" triggers, in wich I look for authors categories, and concatenate its "category_name" fields saving this value in my custom field as you can see in next code:

function onBeforeProductCreate($productData, $do){
		$autores='';
		$primero=true;
		foreach ($productData->categories as $categoria){
			$class = hikashop_get('class.category');
			$cate = $class->get((string) $categoria);
			if ($cate->category_parent_id == JText::_('CAT_AUTORES')){ 
				if ($primero){
					$autores=$autores.$cate->category_name;
					$primero=false;
				}else{
					$autores=$autores.'; '.$cate->category_name;
				}
			}
		}
		$productData->autores=$autores;
		
		return true;
	}

It works perfectly when I create or modify a product in the backend, but when I import products from a CSV file, it doesn't work.

My question:
Is there any trigger that I can use in my plugin to do the same operation when imports products?

Thanks in advance

Last edit: 9 years 7 months ago by pljuarez.

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 7 months ago #198023

No. During the import process, the plugins triggers are not called because it would require too many resources and also because the data objects don't have the same structure as when you save a product in the backend.

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

  • Posts: 79
  • Thank you received: 3
9 years 7 months ago #198336

Ok, then, I saw your " Create you own mass action plugin " tutorial.

Can I program a mass action plugin to do this action with every product after import from a CSV file?.

If answer is wes, what functions may I program?
Note I want to do the actions I have described before, with all products (I think, I don't need filters)

In addition, looking for information, I see /plugins/hikashop/massaction_product/massaction_product.php file and inside this code I found "onBeforeProductCreate" and "onBeforeProductUpdate" functions.

Are these the functions wich I shoud override in my mass action plugin?

Thanks in advance.

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 7 months ago #198396

Hi,

You can program a mass action plugin to do that yes.
I invite you to check the different massaction plugins that are installed with HikaShop (one in the system group, the others in the hikashop group) where you'll see the several functions that can be implemented for the mass action system.
First, you'll want to implement the onMassactionTableActionsLoad(&$table,&$actions,&$actions_html,&$loadedData) trigger and just have one line of code in that function:
$actions='My custom action';

Then, you'll want to implement the onProcessProductMassActionmy_custom_action(&$elements,&$action,$k) trigger where you'll be able to add your code in order to update the data of the products with a MySQL update query.

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

  • Posts: 79
  • Thank you received: 3
9 years 7 months ago #198494

Thanks Nicolas. I'll try it.

Regards

Last edit: 9 years 7 months ago by pljuarez.

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

  • Posts: 79
  • Thank you received: 3
9 years 7 months ago #198662

Hello, again. Yesterday I finished my first mass action plugin AND IT WORKS!!. For this reason I consider this thread closed

Thanks again.

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

Time to create page: 0.082 seconds
Powered by Kunena Forum