product image, where association to product_id?

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #20549

Hello,

I want to display a few products in a module, which I'm doing on my own, but I can not find the associated link to the pictures of the product. The pictures are stored in media/.... , but how can I display the pictures of e.g a product with the product_id of '20' (in MySQL)?
If the link would be saved in the database, I could do something like that:

$res = "SELECT * FROM bak_hikashop_product WHERE product_id = 20";

while ($data = mysql_fetch_assoc($res))
{
   $product_name       = $data["product_name"];
   $product_image_link = $data["PRODUCT_LINK"]        // doesn't exist in table
   
   echo "<img src='$product_image_link'>";
}

But how can I get the link to the picture belonging to the product?

Thank You,

Storm =)

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20552

The pictures links with products are sorted in the hikashop_file table.
Like that:

SELECT * FROM jos_hikashop_file WHERE file_type="product" AND file_ref_id=20

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #20557

Thank you for the quick reply :)
I'm gonna take a look at it, but why is e.g in the file views->product->tmpl->show.php no query with "SELECT...."?

Regards,

Storm

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20570

The data is loaded separately. The views are only for displaying the data. That's the way joomla is structured.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #20610

The table doesn't show every product image. There are just 19 Datasets, but I have far more than 19 Products with images.
The path does no work, too :o

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20615

All the images are linked in that table. If you have only 19 entries in that table, it means that you have only 19 images linked to products.

The path there is a relative path from the upload folder specified in the configuration. That's maybe why you're saying that it doesn't work ? You should prepend to it the upload path from the configuration.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #20618

$query = "SELECT * FROM bak_hikashop_file WHERE file_ref_id = '15'";
   $res   = mysql_query($query);
   
   while ($product_data = mysql_fetch_assoc($res))
   {
      $path = $product_data["file_path"];
	  echo "<img src='localhost/joomla/media/com_hikashop/upload/thumbnail/$path'>";
	  
	  
   }

The images in the upload folder have a different name than the path.
E.G:

In table: test_img.jpg
In folder: test_img_128495603.jpg

The code above would give me the path, if the names were equal.

Regards,

Storm

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20641

The path in the table and the name of the image are the same. Otherwise, no one would be able to display any images with HikaShop.
Since it works everywhere, it must be something else which is creating the problem.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #20648

I don't get it...
The images in the folder: joomla/media/com_hikashop/upload are not equal to the paths in the table.
I don't know why, but the images in the folder have got a number after their name.
Or am I in the wrong folder?

:blink:

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20661

if the image already exists in the folder when you upload it via the interface, the system appends a number to it and use that new name for the file in the database and in the upload folder.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #20823

Hello,
but why doesn't it work, when I take the value of path_file, e.g "450 8mb11 pic3.jpg"
and add it to the location of the upload folder:

localhost/joomla/media/com_hikashop/upload/thumbnail/450 208mb11 20pic3.jpg

It does not find the file...

Thank You for your help :)

Last edit: 13 years 4 months ago by Storm15.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20834

You added two 20 in the name of the image.

If the path_file has a file name which doesn't exists in the upload folder, there is only one reason: that file has been deleted manually via FTP and you should not see it when editing the product in the back end but instead you should see the default bar code image.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #20968

Hello :)

I've got it, there are two tables, one with the prefix "bak" and one with "jos".
I haven't noticed the "jos"- table (it's the right one).
Is the "bak" table important? Can I drop this table?

Regards,

Storm

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
13 years 4 months ago #20980

When you install joomla on a database where you already had a previous joomla before, all the tables are renamed with their prefix being changed to bak_, so they are not used anymore.

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

Time to create page: 0.080 seconds
Powered by Kunena Forum