Fix bug in battery:generate_compatibility_json command #212

This commit is contained in:
Kendrick Chan 2019-05-27 09:57:20 +08:00
parent 144156e377
commit 92c0f2d169

View file

@ -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;
}