From 92c0f2d1699a13b99c49c8cd1f35aae61ad9e622 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 27 May 2019 09:57:20 +0800 Subject: [PATCH] Fix bug in battery:generate_compatibility_json command #212 --- .../GenerateBatteryCompatibilityCommand.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Command/GenerateBatteryCompatibilityCommand.php b/src/Command/GenerateBatteryCompatibilityCommand.php index dca7f36b..57e20076 100644 --- a/src/Command/GenerateBatteryCompatibilityCommand.php +++ b/src/Command/GenerateBatteryCompatibilityCommand.php @@ -36,7 +36,7 @@ class GenerateBatteryCompatibilityCommand extends Command foreach ($vms as $vm) { $mfg_name = $vm->getName(); - $this->vmfg_index[$mfg_name] = $vm; + // $this->vmfg_index[$mfg_name] = []; // get vehicles from manufacturer $make_array = []; @@ -51,7 +51,8 @@ class GenerateBatteryCompatibilityCommand extends Command $comp_batt['id'] = $battery->getID(); $comp_batt['name'] = $battery->getModel()->getName() . ' ' . $battery->getSize()->getName(); - $comp_batt['image_url'] = $battery->getImageFile(); + $comp_batt['image_url'] = '/assets/img/products/' . strtolower($battery->getModel()->getName()) . '.png'; + $comp_batt['description'] = ''; //$comp_batt['description'] = $battery->getDescription(); // store the selling price for comparison @@ -67,10 +68,16 @@ class GenerateBatteryCompatibilityCommand extends Command //$comp_batt['description'] = $battery->getDescription(); } } - $make_array[$vehicle->getMake()][$vehicle->getModelYearFormatted()] = $comp_batt; + + // check if no compatible batteries + if (!empty($comp_batt)) + $make_array[$vehicle->getMake()][$vehicle->getModelYearFormatted()] = $comp_batt; } - $this->vmfg_index[$mfg_name] = $make_array; + + // check if empty + if (!empty($make_array)) + $this->vmfg_index[$mfg_name] = $make_array; }