Skip to main content

Retrieving Field Group data

Once field groups are configured within the Custom Field Groups module in PrestaShop, you can retrieve their data using various methods. Below are the three primary methods for retrieving field group data:

Method 1: Front office templates

For all entities supported by the Custom Field Groups module, you can access field group data via a front controller variable provided by the module:

/some-template.tpl
{* By entity object *}
{$modules.customfieldgroups.data->get($object)}
/some-template.tpl
{* By entity name and id *}
{$modules.customfieldgroups.data->get('product', $product.id)}

This method returns all field groups and their associated field data for the requested entity, which can be used directly in your front office templates.

Method 2: PHP code integration

To retrieve field group data programmatically from PHP code, use the DataRetrieverFacade class provided by the module:

/SomeClass.php
<?php

function someMethod()
{
$dataRetriever = DataRetrieverFacade::getInstance();

// Retrieve data by entity object
$data = $dataRetriever->get($object);

// Retrieve data by entity name and id
$data = $dataRetriever->get('customer', $customer->id);
}

By leveraging these methods, you can efficiently retrieve and display field groups data added through the Custom Field Groups module across various parts of your PrestaShop site.