<?php

declare(strict_types=1);

namespace External\HannahBundle\Admin\lists;

require_once $cfg['Path']['shared_version'].'bundles/KupShop/ReturnsBundle/Admin/lists/ReturnsList.php';

class ReturnsList extends \ReturnsList
{
    protected function getStoreName(int $storeId): string
    {
        static $storeSapIds;

        if ($storeSapIds === null) {
            $storeSapIds = sqlQueryBuilder()
                ->select('id_store, id_sap')
                ->from('sap_stores')
                ->execute()->fetchAllKeyValue();
        }

        $storeNameParts = array_filter([
            $storeSapIds[$storeId] ?? null,
            parent::getStoreName($storeId),
        ]);

        return implode(' - ', $storeNameParts);
    }
}

return ReturnsList::class;
