Search products by product_code!?

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #37670

Today, after importing some products throught the csv import i've realized that if i put in the searchbox the product_code it doesnt get the products listed, how can i accomplish that?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 9 months ago #37786

You're talking about the back end ? If so, make sure that you select the "all sub elements" filter on the right.

If you're talking about the joomla search on the front end, make sure that you configured the hikashop products search plugin to use that product_code field.

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #37797

got it!

But now i see that it searches just in the main product's product_code, how can i make it look in the variants code too?

i.e.: I have man product with code 813-gen that stands for a tipe of marine cord but that marine cord is available in 2mm, 3mm and 5mm each one with a diferent code on the catalog but inside the product "marine cord" so i got:
813-gen for the "marine cord"
813002 for the "marin cord" "2mm"
813003 for the "marin cord" "3mm"
813005 for the "marin cord" "5mm"

when i search for 813005 it give me back nothinw, while i'm expecting to get "marin cord" "5mm" (buy it now!)

How can this be sorted out?

Last edit: 12 years 9 months ago by protorob.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 9 months ago #37811

Yes, the plugin only handle the search of information on main products, not variants.

To do that, you would have to edit the code of the plugin: plugins/search/hikashop_products.php

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #37812

can you give me a clue about the lines to modify please?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 9 months ago #37912

The easiest is to change:

$filters = array('a.product_published=1','a.product_type=\'main\'');

to:
$filters = array('a.product_published=1');

and remove the block:
		if(hikashop_level(2)){
			$catFilters = array('category_published=1','category_type=\'product\'');
			hikashop_addACLFilters($catFilters,'category_access');
			$db->setQuery('SELECT category_id FROM '.hikashop_table('category').' WHERE '.implode(' AND ',$catFilters));
			$cats = $db->loadResultArray();
			if(!empty($cats)){
				$filters[]='b.category_id IN ('.implode(',',$cats).')';
			}
		}

		$leftjoin=' INNER JOIN '.hikashop_table('product_category').' AS b ON a.product_id=b.product_id';

But it won't handle the unpublished categories and we display the variants even if they are associated to a product within unpublished categories.

The following user(s) said Thank You: protorob

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #37953

i think i can live with that, is just a matter of not having unpublished categories with unpublished products.
By the time i'll be finishing the whole website (is some kind of hardware store for ships and sealife in general) i'm shure that hikashop will be at version 2.8 and this issue will be solved.

Thanks in advance

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #37962

Now with the modification you suggested actually it finds "some" product when i put the product_code in the search field but it doesn't shows the product name neither a link to open it. I can't figure how to solve this yet

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 9 months ago #37965

That's because you didn't set a name in each of your variants.
Thus, the plugin display nothing for the name of the result.
You would have to do an additional query to load the corresponding product information in order to use the name of the name product and not the name of the variant.
So before the line:
if(method_exists($app,'stringURLSafe')){

add that:
$class = hikashop_get('class.product');
$variant = $class->get($row->id);
$product = $class->get($variant->product_parent_id);
$row->title = $product->product_name;

The following user(s) said Thank You: protorob

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #37966

Ok, i've realized that if the variant doesn't have any name it does'nt shows anything in the search results.
I've updated my csv giving to the variants the same product name as the main product and adding the name of the variant at the end so is easy to see if the product is the one we're searching.

When i click on the product it effectively goes to the product i'm looking for but the name of the product doesn't includes the variant as expected.
If you select another variant from the dropdown it add it at the end of the title after a ":"
But if you click automatically "add to cart" it put it on the cart with the right information.

Could be a solution by now.

Thanks

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #37967

that's a better solution!
Thank's Nicolas.

I'm adding the file i've modified as an attachment to this email.
So, for information, i'm using:

joomla 1.7.0 and
hikashop 1.5.6

the file attached overwrites this one

plugins/search/hikashop_products/hikashop_products.php

Attachments:
Last edit: 12 years 9 months ago by protorob.

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #37974

Another little thing,
It is possible to have the name of the variant(s) added to the title in the product search results?
I'm not good at all with php and i dont want to mess everything up.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 9 months ago #37980

Sure. Instead of:
$row->title = $product->product_name;

you should use:
$row->title = $product->product_name.' '.$row->title;

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #38001

unfortunately it doesn't work as expected.

When i search for the product variant by the code it actually gives me the name of the main product and when i click on the link on the search results it goes to the product with the correct variant selected but the title remains the one of the main product.

Lets say, the main product is "Marine Cord" with the title "Marine Cord".
As soon as i choose a variant, i.e. 6mm it ads ":6mm" at the end of the title so it becomes "Marine Cord : 6mm".
I've added an specific product code for that variant of the marine cord, let's say 82106, and when i search for it in the search module i'm still getting only "Marine Cord" when "Marine Cord : 6mm" is expected.

I feel that the solution is so simple...

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 9 months ago #38073

Could you give a link to that search page so that we can see the problem ?

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #38085

Ok, the website is this one (i'm giving you the link to the first page of the catalog)

www.euromarnautica.com/it/shop/


you can test the search functionality with this product(the search module is that orange one up there in top-right corner of the header):


Main Product: TRECCIA STANDART IN POLIESTERE COLORE BIANCO
Main product_code: 811-gen

Product Variants codes:
5mm = 81105
6mm = 81106
7mm = 81107
8mm = 81108
10mm = 81110
12mm = 81112
14mm = 81114
16mm = 81116
18mm = 81118
20mm = 81120
22mm = 81122
24mm = 81124
26mm = 81126
28mm = 81128
30mm = 81130

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 9 months ago #38176

That's not a problem of the plugin.
IT's just the way the system is done for the display of the product page.
If you want to do that like you want, you will have to edit the file "show_default" (since 1.5.6) via the menu Display->Views and change the line:
if (isset ($this->element->main->product_name))

to:
if (hikashop_getCID('product_id')!=$this->element->product_id && isset ($this->element->main->product_name))

The following user(s) said Thank You: protorob

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

  • Posts: 96
  • Thank you received: 14
12 years 9 months ago #38410

Cool, now the title on the main product is working as expected!
The only thing that remains unchanged is the fact that in the search results i'm still having only the name of the main product without the ":variant selected" sufix
I think that if the modification is too heavy is something i can live with if it is going to be fixed in the near future.

The other question i have is related to the upgrading of the free to the business version, i'll follow the procedures indicated in the forums for upgrading my site to joomla 2.5 and eventually make a transition of the whole hikashop to the new version of joomla.

Am i going to modify these code again when my new installation of joomla+hika will be ready?

Thank's in advnance

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 9 months ago #38553

We'll look at adding an option to handle that for next version.

If you upgrade before, you will indeed have to redo your modifications after the update/upgrade.

The following user(s) said Thank You: protorob

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

Time to create page: 0.075 seconds
Powered by Kunena Forum