I would like to edit the kpi section on the admin orders page,in Prestashop 1.7, so i created a module, i tried to use a custom module class, in the module's main php file, but i got error
so I created a new CmCustomKpi class, in modules/module_name/src/Kpi/CmCustomKpi.php
namespace Prestashop\Module\CommissionEmployee\Kpi;
use Context;
use HelperKpi;
use PrestaShop\PrestaShop\Kpi\KpiInterface;
/**
* @internal
*/
final class CmCustomKpi implements KpiInterface
{
/**
* {@inheritdoc}
*/
public function render()
{
$translator = Context::getContext()->getTranslator();
$helper = new HelperKpi();
$helper->id = 'box-total-user';
$helper->icon = 'account_box';
$helper->color = 'color1';
$helper->title = $translator->trans('Total users', [], 'Admin.Global');
$helper->subtitle = $translator->trans('30 days', [], 'Admin.Global');
$helper->value = 20;
return $helper->generate();
}
}
In the beginning of my module main php file I added
**use Prestashop\Module\CommissionEmployee\Kpi\CmCustomKpi;**
And in hook function
public function hookActionOrdersKpiRowModifier(array $params)
{
$params['kpis'][] = new **CmCustomKpi**();
}
I got this error
Attempted to load class "CmCustomKpi" from namespace "Prestashop\Module\CommissionEmployee\Kpi".
Did you forget a "use" statement for another namespace?
Easy way: don't use namespace. Include your file and use it.
Hard way: Create your namespace using composer(You\ModuleName), then use your custom namespace.
Sample from PrestaShop: