Add category name in response if sap battery is null. #562

This commit is contained in:
Korina Cordero 2021-05-18 10:18:42 +00:00
parent 4d1859afa4
commit 3488d5f9a9

View file

@ -244,8 +244,14 @@ class CustomerWarrantyController extends APIController
$sku = $warr_serial->getSKU();
// check if sku is null
$batt = null;
$cat_name = '';
if ($sku != null)
$batt = $em->getRepository(SAPBattery::class)->find($sku);
else
{
// get the category name of the serial
$cat_name = $warr_serial->getMetaInfo('category_name');
}
// TODO: put this in a config file
$image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png';
@ -260,7 +266,7 @@ class CustomerWarrantyController extends APIController
else
{
$battery = [
'brand' => '',
'brand' => $cat_name,
'size' => '',
'image_url' => '',
];