[Skip to main content](#vessel-content)

#   Get product image path

##

- **[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")**
- [![kyratn's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/redswirl.jpg)](/forum/user/38342-kyratn "View kyratn's Profile") Topic Author
- [ Offline](/forum/user/38342-kyratn)

Less More

- Posts: 1119
- Thank you received: 114
-
- [](http://kyra.lt)
-

7 years 5 months ago [\#307472](#307472) by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")  *[Get product image path](/forum/31-development/897641-get-product-image-path#307472 "Hi,  How would i get product image in custom module. Doing like this:  Doesn't return image at all inside product variable.  The only way i could get it, was using sql query like this:  But i think there should be a better way doing this with hikashop code it self??  Please advise.  Thank you")* was created by *[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")*

Hi,

How would i get product image in custom module. Doing like this:
Code:

&lt;?php $productClass = hikashop_get('class.product'); $product = $productClass-&gt;get($id); var_dump($product); ?&gt;

Doesn't return image at all inside product variable.

The only way i could get it, was using sql query like this:
Code:

$db = JFactory::getDbo(); $sql = 'SELECT file_path FROM '.hikashop_table('file').' WHERE file_type="product" AND file_ref_id='.$id; $db-&gt;setQuery($sql); $path = $db-&gt;loadObjectList();

But i think there should be a better way doing this with hikashop code it self??

Please advise.

Thank you

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzY0MS1nZXQtcHJvZHVjdC1pbWFnZS1wYXRoP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

7 years 5 months ago [\#307474](#307474) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Get product image path](/forum/31-development/897641-get-product-image-path#307474 "Hi,  How would i get product image in custom module. Doing like this:  Doesn't return image at all inside product variable.  The only way i could get it, was using sql query like this:  But i think there should be a better way doing this with hikashop code it self??  Please advise.  Thank you")*

Hi,

If you do this, you'll get the images data preloaded in $product: Code:

&lt;?php $productClass = hikashop_get('class.product'); $product = $productClass-&gt;getProduct($id); var_dump($product); ?&gt;

Then, if you want the URL of the image it's really easy: Code:

&lt;?php foreach($product-&gt;images as $image) { echo JURI::base(true).'images/com_hikashop/upload/'.$image-&gt;file_path; } ?&gt;

And you can replace images/com_hikashop/upload/ with the path you actually configured in the "upload folder" setting of the HikaShop configuration if you changed the default one.

The following user(s) said Thank You: [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzY0MS1nZXQtcHJvZHVjdC1pbWFnZS1wYXRoP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")**
- [![kyratn's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/redswirl.jpg)](/forum/user/38342-kyratn "View kyratn's Profile") Topic Author
- [ Offline](/forum/user/38342-kyratn)

Less More

- Posts: 1119
- Thank you received: 114
-
- [](http://kyra.lt)
-

7 years 5 months ago [\#307494](#307494) by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")  Replied by *[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")* on topic *[Get product image path](/forum/31-development/897641-get-product-image-path#307494 "Hi,  How would i get product image in custom module. Doing like this:  Doesn't return image at all inside product variable.  The only way i could get it, was using sql query like this:  But i think there should be a better way doing this with hikashop code it self??  Please advise.  Thank you")*

Hi,

Well that's strange. Doing var_dump($product) i couldn't see image or file path at all... Now it works.

Thank you

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzY0MS1nZXQtcHJvZHVjdC1pbWFnZS1wYXRoP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

7 years 5 months ago [\#307495](#307495) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Get product image path](/forum/31-development/897641-get-product-image-path#307495 "Hi,  How would i get product image in custom module. Doing like this:  Doesn't return image at all inside product variable.  The only way i could get it, was using sql query like this:  But i think there should be a better way doing this with hikashop code it self??  Please advise.  Thank you")*

Hi,

The code you gave in your first message was using the "get" function of class.product which doesn't load the images. The code I gave you uses the "getProduct" function which also load the images.

The following user(s) said Thank You: [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzY0MS1nZXQtcHJvZHVjdC1pbWFnZS1wYXRoP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")**
- [![kyratn's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/redswirl.jpg)](/forum/user/38342-kyratn "View kyratn's Profile") Topic Author
- [ Offline](/forum/user/38342-kyratn)

Less More

- Posts: 1119
- Thank you received: 114
-
- [](http://kyra.lt)
-

7 years 5 months ago [\#307535](#307535) by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")  Replied by *[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")* on topic *[Get product image path](/forum/31-development/897641-get-product-image-path#307535 "Hi,  How would i get product image in custom module. Doing like this:  Doesn't return image at all inside product variable.  The only way i could get it, was using sql query like this:  But i think there should be a better way doing this with hikashop code it self??  Please advise.  Thank you")*

Hi,

Thank you Nicolas. I haven't noticed it ![:)](/media/kunena/emoticons/3.png ":)")

Would be great if you could improve development documantation under code samples. Because sometimes it's hard to find some code samples even via forum.

Thank you

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzY0MS1nZXQtcHJvZHVjdC1pbWFnZS1wYXRoP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.070 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
