Skip to main content

Getting product badges from PHP

2 years 11 months ago - 2 years 11 months ago #356916 by dyvel
-- 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:
Code:
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: 2 years 11 months ago by dyvel.

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

2 years 11 months ago #356919 by dyvel
Never mind - that was easier than I thought :-)
I just added these 2 lines of code:
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.053 seconds
Powered by Kunena Forum