display next product image

  • Posts: 1119
  • Thank you received: 114
8 years 7 months ago #238149

Hi,

What code I could use to add image for the next or previous product buttons?
My code looks something like this:

<a href="<?php echo $this->links->next;?>"><span class="pull-left"><i class='icon-angle-left'></i> <?php echo $this->links->next_product->product_name;?></span>
                        <img src="NEXT_PRODUCT_IMG_PATH" height="145" width="115"></a>

Thanks

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
8 years 7 months ago #238241

Hi,

You'll need to add a MySQL query in order to load the data of the images from the hikashop_file table and then use the getThumbnail of the helper.image to generate the thumbnail and finally echo its URL inside the src of an img tag.

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

  • Posts: 1119
  • Thank you received: 114
8 years 7 months ago #238361

Hi,

As usual thank you for replay Nicolas.
I see I need to do 3 things. Only one is the issue for me. How to add a MySQL query? Could you please give me some quick example?

Regards

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
8 years 6 months ago #238376

Hi,

It's quite easy actually:

<?php
$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__hikashop_file WHERE file_type=\'product\' AND file_ref_id=\''.(int)$this->links->next_product->product_id.'\'');
$image = $db->loadObject(); ?>

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

  • Posts: 217
  • Thank you received: 4
8 years 1 month ago #251248

Hello, how can I show image then? :)


Thank you

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 1 month ago #251250

Hi,

You can take a look at the code in the view "product / show_block_image" and see how the image helper and the function getThumbnail can be used.

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: 217
  • Thank you received: 4
8 years 1 month ago #251294

Thank you. I did it!

Now it shows me image of next product.

Can you also advise me how to load next product of next product in this way?


Thís ís my current code:

$db->setQuery('SELECT * FROM #__hikashop_file WHERE file_type=\'product\' AND file_ref_id=\''.(int)$this->links->next_product->product_id.'\'');
$img1 = $db->loadObject(); 

$img = $this->image->getThumbnail(@str_replace("-2","-1",$img1->file_path), array('width' => $width, 'height' => $height), $image_options);
echo '<img class="'.$classname.'" title="'.$this->escape(@$img1->file_description).'" alt="'.$this->escape(@$img1->file_name).'" src="'.$img->url.'"/>';

Last edit: 8 years 1 month ago by FilipHradil.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
8 years 1 month ago #251329

Hi,

The next product is not known. So it's more complex as it will require using a complex algorithm like there is in the components/com_hikashop/views/product/view.html.php file to initialize the $this->links variable but basing yourself on the $this->links->next_product variable instead of $this->element

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

Time to create page: 0.077 seconds
Powered by Kunena Forum