Display Products When You Click On Brand Name Title

  • Posts: 966
  • Thank you received: 11
  • Hikashop Business
3 years 10 months ago #331994

-- HikaShop version -- : 4.4.1

Is it possible that when I'm viewing an item on the details page, when I click on the brand name, it displays all the items for that brand? I've seen a few sites that do that and I'd like to do that too.

Please attached see picture.

Thanks!

Attachments:

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

  • Posts: 83403
  • Thank you received: 13497
  • MODERATOR
3 years 10 months ago #332012

Hi,

By default in HikaShop, the brand of a product displays bellow the buttons on the right side of the layout and the brand name is clickable with a link to the products of that brand.
So there should be nothing to do.
However, I can see that your product page has been customized (by you, your developer or your template provider) to add the brand name at the top of the right side of the product page layout. So I don't know what code you have there and thus I can't say what it should be to have the link.
I can only recommend to check the code we have in components/com_hikashop/views/product/tmpl/show_block_dimensions.php via FTP. There, at the bottom of the file, you can see the code we use to display the brand with its link.

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

  • Posts: 966
  • Thank you received: 11
  • Hikashop Business
3 years 10 months ago #332049

Hi Nicolas,

I removed the Show_Default customization that I made, but when I did that I did not see the Brand Name like you suggested, maybe I'm misunderstanding.

So I looked at the show_block_dimensions.php file that you suggested and tried to figure out how to get it to work but I keep getting errors so I'm not sure what I'm doing wrong. Below is the code for the Brand Name that I had found on the Forum some time back that I'm using on the page.

<h1 class="product-brand-details">
  <?php $class = hikashop_get('class.category');
  $manufacturer = $class->get($this->element->product_manufacturer_id);
  echo $manufacturer->category_name; ?>
</h1>

This is the code in the show_block_dimensions.php that I believe you are referring to.
<?php

}

if($this->config->get('manufacturer_display', 0) && !empty($this->element->product_manufacturer_id)){

	$categoryClass = hikashop_get('class.category');

	$manufacturer = $categoryClass->get($this->element->product_manufacturer_id);

	if($manufacturer->category_published){

		$menuClass = hikashop_get('class.menus');

		$Itemid = $menuClass->loadAMenuItemId('manufacturer','listing');

		if(empty($Itemid)){

			$Itemid = $menuClass->loadAMenuItemId('','');

		}

		$categoryClass->addAlias($manufacturer);

		echo JText::_('MANUFACTURER').': '.'<a href="'.hikashop_contentLink('category&task=listing&cid='.$manufacturer->category_id.'&name='.$manufacturer->alias.'&Itemid='.$Itemid,$manufacturer).'">'.$manufacturer->category_name.'</a>';

		echo "<span style='display:none;' itemprop='brand'>". $manufacturer->category_name ."</span>";

	}

}

Thanks!

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

  • Posts: 83403
  • Thank you received: 13497
  • MODERATOR
3 years 10 months ago #332061

Hi,

You can just replace your code with:

<h1 class="product-brand-details">
  <?php 
$categoryClass = hikashop_get('class.category');

	$manufacturer = $categoryClass->get($this->element->product_manufacturer_id);

		$menuClass = hikashop_get('class.menus');

		$Itemid = $menuClass->loadAMenuItemId('manufacturer','listing');

		if(empty($Itemid)){

			$Itemid = $menuClass->loadAMenuItemId('','');

		}

		$categoryClass->addAlias($manufacturer);

		echo <a href="'.hikashop_contentLink('category&task=listing&cid='.$manufacturer->category_id.'&name='.$manufacturer->alias.'&Itemid='.$Itemid,$manufacturer).'">'.$manufacturer->category_name.'</a>';
 ?>
</h1>

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

  • Posts: 966
  • Thank you received: 11
  • Hikashop Business
3 years 10 months ago #332094

Hi Nicolas,

The code that you provided was giving me this error:

0 - syntax error, unexpected '<'


I revised this part of the code and it works (see below). I just want to check though to make sure what I did is ok and won't mess anything up.
echo <a href="'.hikashop_contentLink('category&task=listing&cid='.$manufacturer->category_id.'&name='.$manufacturer->alias.'&Itemid='.$Itemid,$manufacturer).'">'.$manufacturer->category_name.'</a>';

This is what I have now:
<h1 class="product-brand-details">
<?php 
 $categoryClass = hikashop_get('class.category');
	$manufacturer = $categoryClass->get($this->element->product_manufacturer_id);
		$menuClass = hikashop_get('class.menus');
		$Itemid = $menuClass->loadAMenuItemId('manufacturer','listing');
		if(empty($Itemid)){
			$Itemid = $menuClass->loadAMenuItemId('','');
		}
		$categoryClass->addAlias($manufacturer);
		echo JText::_('').' '.'<a href="'.hikashop_contentLink('category&task=listing&cid='.$manufacturer->category_id.'&name='.$manufacturer->alias.'&Itemid='.$Itemid,$manufacturer).'">'.$manufacturer->category_name.'</a>';
 ?>
</h1>

Thanks!

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

  • Posts: 83403
  • Thank you received: 13497
  • MODERATOR
3 years 10 months ago #332101

Hi,

Yes, my bad. That was a wrong copy/paste. It's fine like that.

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

  • Posts: 966
  • Thank you received: 11
  • Hikashop Business
3 years 10 months ago #332185

No worries. I appreciate your help. Thanks!

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

Time to create page: 0.062 seconds
Powered by Kunena Forum