get picture of product

  • Posts: 21
  • Thank you received: 0
  • Hikashop Business
9 years 8 months ago #193840

-- HikaShop version -- : 2.3.5

hy ,

i want display picture and link to a product

the object $product dont have this information

$productClass = hikashop_get('class.product');
$product=$productClass->get($product_id);

www.hikashop.com/support/support/documen...umentation.html#code

thanks for help

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

  • Posts: 12953
  • Thank you received: 1778
9 years 8 months ago #193873

Hello,
Can you give us more information about what do you want to do, like where do you exactly want to display it ?
Thanks.

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

  • Posts: 21
  • Thank you received: 0
  • Hikashop Business
9 years 8 months ago #194009

hy
i want display it in my component , so i code a function in this way :

function get_image_product($id) {

$db = JFactory::getDbo();

$query = $db->getQuery(true);

$query->select(array('file_path'));

$query->from($db->quoteName('#__hikashop_file'));

$query->where($db->quoteName('file_ref_id') . ' = ' . $id);

$db->setQuery($query);

return $db->loadObject()->file_path;

}

if you have a better and a cleaner way , thank you to tell me how .

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

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #194019

Hi,

You code is correct, what is missing is the folder path, you can get it thanks to:

$fileClass = hikashop_get('class.file');
$folderPath = $fileClass->get('image');

To get all the product data, you can too use the code:
$productClass = hikashop_get('class.product');
$productClass->getProducts($id);
$fullProduct = $productClass->products[$id];

The following user(s) said Thank You: mcambou1

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

  • Posts: 21
  • Thank you received: 0
  • Hikashop Business
9 years 8 months ago #194619

hy

one last question , how can i get the add to cart button ?

thanks for help :)

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

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #194622

Hi,

Whn you are in the backend, in Product, edit a product, then in the toolbar you will see a button "add to cart html", click on it.
This will display the code to add a product to the cart directly, so you can use this code and make it more dynamic to adapt it for each products.

The following user(s) said Thank You: mcambou1

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

  • Posts: 21
  • Thank you received: 0
  • Hikashop Business
9 years 8 months ago #194960

awesome !

thanks for help :)

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

Time to create page: 0.059 seconds
Powered by Kunena Forum