Prev/next product buttons problem

  • Posts: 344
  • Thank you received: 3
11 years 5 months ago #76906

Hikashop 1.6

I have enabled the "Show shortcuts to other category products"
The prev/next buttons are displaying fine.

There are two problems:

1. The button on the right side ain't working, you can't click on it.
The button on the left side works. How can I fix it ?

2. When I click on the button to the left (the one that works) it does not take me to the previos product, it looks like it takes me to a random picked product.
How can I fix this ?

URL for my test site is:
www.kvikkimedia.no/nettbutikk/
please check.

Tnx

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

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #76976

Hi,

1. That's because the right product part div is hover the button, so you can't click on it. Try to set these properties in the css file:
2. These buttons are here to navigate between products in the same category, I think that your products are in many categories, that's why the products related seem's to be random picked.

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

  • Posts: 344
  • Thank you received: 3
11 years 5 months ago #77013

Hi!
Tnx for reply

I fixed the CSS problem, so that's OK.

Yes that is correct that my product are in different categories.

Is there anyway we can get the navigation next/prev only to switch products within the given category ?

Last edit: 11 years 5 months ago by river.

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

  • Posts: 26017
  • Thank you received: 4004
  • MODERATOR
11 years 5 months ago #77161

Hi,

How do you want to specify this given category ?

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: 344
  • Thank you received: 3
11 years 5 months ago #77517

I can see that the navigation buttons are following the order in which the products have in the Hikashop back-end.

Anyway this is the way it should be:
The navgation buttons do not navigate you to a new category even tough the product is placed in two categories, and the navigation button should also follow the product order that is set in the front'end.

Is there any way to fix this ?

Tnx

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

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #77651

Hi,

It's our first request about the navigation buttons, so I think that it's a "special" case.
If you want to change the products linked, you have to edit the file "components/com_hikashop/views/product/view.html.php" and in the function "show()" you can change the request which is loading the related products.

This part is:

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

			hikashop_addACLFilters($filters,'product_access','b');
			if(!$config->get('show_out_of_stock',1)){
				$filters[]='b.product_quantity!=0';
			}
			$query='SELECT DISTINCT a.product_id FROM '.hikashop_table('product_category').' AS a LEFT JOIN '.hikashop_table('product').' AS b ON a.product_id=b.product_id WHERE '.implode(' AND ',$filters).' GROUP BY a.product_id ORDER BY a.ordering ASC';
			$database->setQuery($query);

It require some PHP knowledge.

Regards.

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

  • Posts: 344
  • Thank you received: 3
11 years 5 months ago #78749

Thank you for reply.
Since my PHP skille are very bad could you please give me some more pointers how to fix this in the "view.html.php" file ?

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

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #78919

If you want that your products point to another products of a certain category, you can order the categories in the product edition page.
By this way, your next/previous products displayed will be the products of the wanted category.

Else you can maybe add something like, "if($product_id == '...') $category_id = '...';" before the code above to set a category to a product.

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

  • Posts: 73
  • Thank you received: 2
10 years 7 months ago #123683

Not really a problem. I was wondering if the name of the product can appear next to the prev/next button; right now just the buttons show and would be nice to see the name of the next or previous item.

Thanks

Attachments:

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

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

Hi,

To get the name of the previous/ next element, you will have to edit the file "components/com_hikashop_views_product/view.html.php" function "show()" and replace:

			if(!empty($articles)){
				foreach($articles as $k => $article){
					if($article == $element->product_id || $article == $element->product_parent_id){
						$links->path= JURI::root();
						$links->path .= 'media/com_hikashop/images/icons/';
						$class = hikashop_get('class.product');
						if(!isset($category_pathway)){
							$pathway = '';
						}else{
							$pathway = $pathway_sef_name.'='.$category_pathway;
						}
						if($k != 0){
							$p = $k - 1;
							$id_previous = $articles[$p];
							$elt = $class->get($id_previous);
							$class->addAlias($elt);
							$pathway_sef_name = $config->get('pathway_sef_name','category_pathway');
							$links->previous = hikashop_completeLink('product&task=show&cid='.(int)$id_previous.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
						}
						$n = $k;
						while(isset($articles[$n]) && ($articles[$n]==$element->product_id||$articles[$n]==$element->product_parent_id)){
							$n = $n + 1;
						}
						if(isset($articles[$n])){
							$id_next = $articles[$n];
							$elt = $class->get($id_next);
							$class->addAlias($elt);
							$pathway_sef_name = $config->get('pathway_sef_name','category_pathway');
							$links->next = hikashop_completeLink('product&task=show&cid='.(int)$id_next.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
						}
						break;
					}
				}
			}
By:
$links->previousName = '';
$links->nextName = '';
			if(!empty($articles)){
				foreach($articles as $k => $article){
					if($article == $element->product_id || $article == $element->product_parent_id){
						$links->path= JURI::root();
						$links->path .= 'media/com_hikashop/images/icons/';
						$class = hikashop_get('class.product');
						if(!isset($category_pathway)){
							$pathway = '';
						}else{
							$pathway = $pathway_sef_name.'='.$category_pathway;
						}
						if($k != 0){
							$p = $k - 1;
							$id_previous = $articles[$p];
							$elt = $class->get($id_previous);
							$class->addAlias($elt);
							$pathway_sef_name = $config->get('pathway_sef_name','category_pathway');
							$links->previous = hikashop_completeLink('product&task=show&cid='.(int)$id_previous.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
$links->previousName = $elt->alias;
						}
						$n = $k;
						while(isset($articles[$n]) && ($articles[$n]==$element->product_id||$articles[$n]==$element->product_parent_id)){
							$n = $n + 1;
						}
						if(isset($articles[$n])){
							$id_next = $articles[$n];
							$elt = $class->get($id_next);
							$class->addAlias($elt);
							$pathway_sef_name = $config->get('pathway_sef_name','category_pathway');
							$links->next = hikashop_completeLink('product&task=show&cid='.(int)$id_next.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
$links->nextName = $elt->alias;
						}
						break;
					}
				}
			}

And then edit the view "product / sqhow" via the menu Display > Views, and display the name which will be in the variable:
$this->links->previousName and $this->links->nextName

Be careful, the changes made in the view.html.php file will be lost at each update.
We will improve the code to make it easiest to get some values of the next and previous products in the future.

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

  • Posts: 73
  • Thank you received: 2
10 years 7 months ago #123822

I think I'll just wait until you are able to include this feature in your next version. This is way over my head :)

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

  • Posts: 344
  • Thank you received: 3
10 years 3 months ago #138484

this code been inproved in the latest Hikashop Business version ?

Last edit: 10 years 3 months ago by river.

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

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

Hi,

Yes some improvements have been made in October.

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

Time to create page: 0.112 seconds
Powered by Kunena Forum