filtering relays by type

This commit is contained in:
Christophe LATOUR 2018-01-10 16:40:15 +01:00
parent 99d349691e
commit 90a4de0143

View File

@ -6,4 +6,28 @@ use Antadis\API\Front\Web\Controllers\Relays\SocolissimoController as BaseSocoli
class SocolissimoController extends BaseSocolissimoController
{
public function lists(Request $request, $type) {
$relays = parent::lists($request, $type);
//ON FILTRE LES RELAY PAR TYPE (BPR vs A2P)
$real_relays = new Collection();
$values = \Db::getInstance()->ExecuteS('
SELECT `name`, `value` FROM `'._DB_PREFIX_.'configuration`
WHERE `name` LIKE "%SOFLEXIBILITE%ID"
');
$delivery_values = array_column($values, 'value');
$index = array_search((string)$cart->id_carrier, $delivery_values);
$delivery_mode = 'BPR';
if ($index !== false) {
$delivery_mode = substr($values[$index]['name'], 14, 3);
}
foreach ($relays as $relay) {
if ($relay->extraFields['typeDePoint'] === $delivery_mode) {
$real_relays->push($relay);
}
}
return $real_relays;
}
}