Merge branch '560-display-category-name-if-sku-is-null-in-mobile' into 'master'

Resolve "Display category name if sku is null in mobile"

Closes #560

See merge request jankstudio/resq!665
This commit is contained in:
Kendrick Chan 2021-05-10 07:58:27 +00:00
commit 26293e4239
2 changed files with 20 additions and 6 deletions

View file

@ -3046,8 +3046,15 @@ class APIController extends Controller implements LoggedController
$sku = $warr_serial->getSKU(); $sku = $warr_serial->getSKU();
$batt = null; $batt = null;
$cat_name = '';
if ($sku != null) if ($sku != null)
$batt = $em->getRepository(SAPBattery::class)->find($sku); $batt = $em->getRepository(SAPBattery::class)->find($sku);
else
{
// get the category name of the serial
$cat_name = $warr_serial->getMetaInfo('category_name');
error_log($cat_name);
}
// TODO: put this in a config file // TODO: put this in a config file
$image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png'; $image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png';
@ -3062,7 +3069,7 @@ class APIController extends Controller implements LoggedController
else else
{ {
$battery = [ $battery = [
'brand' => '', 'brand' => $cat_name,
'size' => '', 'size' => '',
'image_url' => '', 'image_url' => '',
]; ];

View file

@ -253,8 +253,15 @@ class CustomerWarrantyController extends APIController
$sku = $warr_serial->getSKU(); $sku = $warr_serial->getSKU();
// check if sku is null // check if sku is null
$batt = null; $batt = null;
$cat_name = '';
if ($sku != null) if ($sku != null)
$batt = $em->getRepository(SAPBattery::class)->find($sku); $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 // TODO: put this in a config file
$image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png'; $image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png';
@ -269,7 +276,7 @@ class CustomerWarrantyController extends APIController
else else
{ {
$battery = [ $battery = [
'brand' => '', 'brand' => $cat_name,
'size' => '', 'size' => '',
'image_url' => '', 'image_url' => '',
]; ];