Hikashop next product button

  • Posts: 102
  • Thank you received: 3
9 years 8 months ago #246636

-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.6.0

Hello,

Is anyone make links between first and last product?

Now it's works like: product 1 > product 2 > product 3
It would be good if: product 1 > product 2 > product 3 > product 1

Circle linked products for better SEO)

Thnx.

Last edit: 9 years 8 months ago by Rabbiteggs.

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

  • Posts: 85441
  • Thank you received: 13965
  • MODERATOR
9 years 8 months ago #246667

Hi,

Thank you for your feedback. That's a good idea.
You can add the code:

if($config->get('circle_around_for_shortcuts', 1)){
					if(empty($links->next) && !empty($links->previous)){
						$id_next = first($articles);
						$elt = $productClass->get($id_next);
						$productClass->addAlias($elt);
						$links->next = hikashop_completeLink('product&task=show&cid='.(int)$id_next.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
						$links->next_product = $elt;
					}
					if(empty($links->previous) && !empty($links->next)){
						$id_previous = end($articles);
						$elt = $productClass->get($id_previous);
						$productClass->addAlias($elt);
						$links->previous = hikashop_completeLink('product&task=show&cid='.(int)$id_previous.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
						$links->previous_product = $elt;
					}
				}
after the code:
if(isset($articles[$n])) {
						$id_next = $articles[$n];
						$elt = $productClass->get($id_next);
						$productClass->addAlias($elt);
						$links->next = hikashop_completeLink('product&task=show&cid='.(int)$id_next.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
						$links->next_product = $elt;
					}
					break;
				}
in the file components/com_hikashop/views/product/view.html.php and that should do it.

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

  • Posts: 102
  • Thank you received: 3
9 years 8 months ago #246715

Thank you very much for you attention.

Something wrong. It doesn't work((

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

  • Posts: 85441
  • Thank you received: 13965
  • MODERATOR
9 years 8 months ago #246735

Hi,

Change the line:
$id_next = first($articles);
to:
$id_next = reset($articles);
in the code I gave and it will work. I've tested it myself.

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

  • Posts: 102
  • Thank you received: 3
9 years 8 months ago #246741

Hello,

I don't know why)) My view.html file in attachment

This message has an attachment file.
Please log in or register to see it.

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

  • Posts: 85441
  • Thank you received: 13965
  • MODERATOR
9 years 8 months ago #246743

Hmm, you have a different version of the code than I do.
You need to add a } before the code and remove one after so that the new code goes outside of the foreach loop.
Like that:

				foreach($articles as $k => $article){
					if($article != $element->product_id && $article != $element->product_parent_id)
						continue;

					$links->path = JURI::root() . 'media/com_hikashop/images/icons/';
					$pathway = '';
					if(isset($category_pathway))
						$pathway = $pathway_sef_name.'='.$category_pathway;

					if($k != 0) {
						$p = $k - 1;
						$id_previous = $articles[$p];
						$elt = $productClass->get($id_previous);
						$productClass->addAlias($elt);
						$links->previous = hikashop_completeLink('product&task=show&cid='.(int)$id_previous.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
						$links->previous_product = $elt;
					}
					$n = $k;
					while(isset($articles[$n]) && ($articles[$n] == $element->product_id || $articles[$n] == $element->product_parent_id)) {
						$n++;
					}

					if(isset($articles[$n])) {
						$id_next = $articles[$n];
						$elt = $productClass->get($id_next);
						$productClass->addAlias($elt);
						$links->next = hikashop_completeLink('product&task=show&cid='.(int)$id_next.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
						$links->next_product = $elt;
					}
					break;
				}
				if($config->get('circle_around_for_shortcuts', 1)){
					if(empty($links->next) && !empty($links->previous)){
						$id_next = reset($articles);
						$elt = $productClass->get($id_next);
						$productClass->addAlias($elt);
						$links->next = hikashop_completeLink('product&task=show&cid='.(int)$id_next.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
						$links->next_product = $elt;
					}
					if(empty($links->previous) && !empty($links->next)){
						$id_previous = end($articles);
						$elt = $productClass->get($id_previous);
						$productClass->addAlias($elt);
						$links->previous = hikashop_completeLink('product&task=show&cid='.(int)$id_previous.'&name='.$elt->alias.'&'.$pathway.$url_itemid);
						$links->previous_product = $elt;
					}
				}

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

  • Posts: 102
  • Thank you received: 3
9 years 8 months ago #246787

Thank you very much. It works well!

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

  • Posts: 1119
  • Thank you received: 114
9 years 8 months ago #246791

Hi,

Will this be added to hikashop it self by default? As this is kinda hack....

Thanks

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

  • Posts: 85441
  • Thank you received: 13965
  • MODERATOR
9 years 8 months ago #246809

Yes, it will be added for the next version of HikaShop.

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

Time to create page: 0.074 seconds
Powered by Kunena Forum