Getting product badges from PHP

  • Posts: 88
  • Thank you received: 19
5 months 4 days ago #356916

-- HikaShop version -- : 5.0.0
-- Joomla version -- : 4.4.0
-- PHP version -- : 8.1

Hi

I have a PHP function that returns a product from Hikashop based on the product id.
The relevant code is:

if (!@include_once (rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) {
	return false;
}

// Product
$productClass = hikashop_get('class.product');
$product = $productClass->getProduct($id);

However, the returned product object from $productClass->getProduct($id) is not "complete" when I compare it to what I see directly in a product listing view. E.g. it does not contains any badges.

Does Hikashop have a way to enrich the product object with badges?

Merci

Last edit: 5 months 4 days ago by dyvel.

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

  • Posts: 88
  • Thank you received: 19
5 months 4 days ago #356919

Never mind - that was easier than I thought :-)
I just added these 2 lines of code:

$classbadge = hikashop_get('class.badge');
$classbadge->loadBadges($product);

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

Time to create page: 0.056 seconds
Powered by Kunena Forum