News:

Support the VirtueMart project and become a member

Main Menu

custom fields not rendered in search results

Started by vmfyelloq19, June 29, 2023, 12:40:07 PM

Previous topic - Next topic

vmfyelloq19

Friends,
I just noticed custom fields do not get rendered in search results.

If I vardump $product = $viewData['product']; in my com_virtuemart/sublayouts/customfields.php template override I can see the custom field data is available,
but the display property is empty/unset.

Is there any way to triggger rendering the custom field to get the html data?

TIA!

yebar16037

#1
do this by adding the following code to your template override:

$product = $viewData['product'];

if (isset($product->customfields)) {
    foreach ($product->customfields as $customfield) {
        $customfield->display = $customfield->renderField('html');
    }
}

This code will first check if the customfields property is set on the product object. If it is, then the code will loop through the custom fields and set each custom field's display property to the custom field's HTML output. Mod edit: spam link removed

Empowering e-commerce excellence with VirtueMart, where online businesses thrive and succeed!