How to show Brand image on the product view

  • Posts: 69
  • Thank you received: 1
10 years 2 weeks ago #152615

-- url of the page with the problem -- :
steiner.taylorbruce.com/index.php?option...kin-glove&Itemid=246
-- HikaShop version -- : HikaShop Business 2.3.0
-- Joomla version -- :Joomla! 3.2.3 Stable
-- PHP version -- : 5.3.28
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- :

Hi,

I would like to alter the product view to show the brand image (in addition to the link to the brand category).

I am working in the mytemplate/html/com_hikashop/product/show_block_product_files.php file and want to enhance the display of the manufacturer/brand. Currently the band name is displayed by HikaShop using this code:
echo JText::_('MANUFACTURER').': '.'<a href="'.hikashop_completeLink('category&task=listing&cid='.$manufacturer->category_id.'&name='.$manufacturer->alias.'&Itemid='.$Itemid).'">'.$manufacturer->category_name.'</a>';

I would like to add custom PHP code to the above to also display the image of this manufacturer/brand. I am not a PHP expert, but I went to the /category/listing.php file near line 47 and copied this code:
<img src="<?php echo $this->image->getPath($this->element->file_path); ?>" class="hikashop_category_image"/>

into the mytemplate/html/com_hikashop/product/show_block_product_files.php file. It got me a partial path to the image, but not the full path.

Can you give me some help on how to retrieve the full path to the brand image from the product view? Can this even be done? If not, do you have any other suggestions? I guess I can create a custom image field for the product, but that would require me to keep the product custom image field in sync with the brand image.

Any help is welcome.

Thanks,

Dennis


______________
Dennis Kmetz

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

  • Posts: 13201
  • Thank you received: 2322
10 years 2 weeks ago #152659

Hi,

This kind of code will give you the full image path of the product brand:

		<?php
		$db = JFactory::getDBO();
		$db->setQuery('SELECT * FROM '.hikashop_table('file').' WHERE file_type = "category" AND file_ref_id = '.(int)$this->element->product_manufacturer_id);
		$image = $db->loadObject();
		$fileClass = hikashop_get('class.file');
		$mainPath = $fileClass->getPath('image');
		$imagePath = $mainPath.$image->file_path;
		var_dump($imagePath);
		?>

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

  • Posts: 344
  • Thank you received: 3
8 years 5 months ago #222201

Xavier wrote: Hi,

This kind of code will give you the full image path of the product brand:

		<?php
		$db = JFactory::getDBO();
		$db->setQuery('SELECT * FROM '.hikashop_table('file').' WHERE file_type = "category" AND file_ref_id = '.(int)$this->element->product_manufacturer_id);
		$image = $db->loadObject();
		$fileClass = hikashop_get('class.file');
		$mainPath = $fileClass->getPath('image');
		$imagePath = $mainPath.$image->file_path;
		var_dump($imagePath);
		?>


Hikashop 2.5.0
Joomla 3.4.5

I tried to aply the above code into the product / show_default file

But it only displays this crazy line.

string(76) "/home/XXXXX/public_html/(PATH TO BRAND IMAGE)

Any idea how to make it work ?

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

  • Posts: 81605
  • Thank you received: 13084
  • MODERATOR
8 years 5 months ago #222218

Hi,

The code Xavier gave you displays the full path of the image.
That's what you asked in your original message and thus that's what you get.

However, reading your first message, what you want is not the code to get the full path of the image but the code to get the HTML for the display of the image.
In that case, it's that code that you want:

<?php
		$db = JFactory::getDBO();
		$db->setQuery('SELECT * FROM '.hikashop_table('file').' WHERE file_type = "category" AND file_ref_id = '.(int)$this->element->product_manufacturer_id);
		$image = $db->loadObject();
		$fileClass = hikashop_get('helper.image');
		$img = $fileClass->getThumbnail($image->file_path, array('width' => '100', 'height' => '100'), array('default' => true,'forcesize'=>$this->config->get('image_force_size',true),'scale'=>$this->config->get('image_scale_mode','inside')));
		echo '<img src="'.$img->url.'/>';
		?>

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

  • Posts: 103
  • Thank you received: 2
6 years 11 months ago #270098

Oh please help! i need to show the logo brand instead of just the name in the product view, but i tried this and other codes with no luck, sometimes the page break so i try again :(

I have a little knowledge of php, but not enough to make this happen, please help me, thank you so much in advance!

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

  • Posts: 26019
  • Thank you received: 4005
  • MODERATOR
6 years 11 months ago #270105

Hello,

The code Nicolas gave here is working ; but for sure it requires some PHP/Development skills in order to know how to use it and paste it correctly in a PHP file.
You already opened a thread for your question ; please do not duplicate your questions, it will be counter productive.
www.hikashop.com/forum/product-category-...on-product-page.html

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: 103
  • Thank you received: 2
6 years 11 months ago #270201

Im sorry, i found another solution using the badge, is kind of double work, but with some special css is working fine for me. Hope in the future you can include the brand image like an option, thank you for your hard work!

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

Time to create page: 0.097 seconds
Powered by Kunena Forum