Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.

You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page

BadgeColumn Type

This basic BadgeColumn displays a raw field data in Grid, associated with a badge.

Available options

Properties Type Expected value
field string required Record field name which column displays.
badge_type string default: success Indicates which field of the row contains the image source. (Allowed values: success, info, danger, warning)

Example usage

<?php
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BadgeColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection;

$badgeColumn = new BadgeColumn('total_spent');
$badgeColumn->setName('Sales');
$badgeColumn->setOptions([
     'field' => 'total_spent',
     'badge_type' => 'success',
     'empty_value' => '--',
]);

$columns = new ColumnCollection();
$columns->add($badgeColumn);