Skip to content

Remove vehicle from garage when only have year false-y bug #75

@drmmr763

Description

@drmmr763

Hi All

I'm running into an issue where when a user has added only a vehicle year to their garage, the 'remove' function gets a bit buggy. This is because the removeVehicle() function is doing an if statement to confirm the object in the session matches the object being removed. I've stepped through the code here.

The remove link fires the controller:
https://github.com/vehiclefits/vfmagento/blob/master/app/code/local/Elite/Vafgarage/controllers/RemoveController.php#L27

The session data is an object of the data model, so it calls up the removeVehicle method in that class:
https://github.com/vehiclefits/vfmagento/blob/master/app/code/local/Elite/Vafgarage/Model/Garage.php#L36-L42

This is where it gets messed up. The if statement there does a check to see that the objects are the same exact objects. The problem is that they're not:

Here I dump the vehicle object from the session and compared it to the vehicle object in the $this->vehicles() list:

The session object:
array(3) {
  ["year"]=>
  string(2) "77"
  ["make"]=>
  string(1) "0"
  ["model"]=>
  string(1) "0"
}

$this->vehicles() object:
array(3) {
  ["year"]=>
  string(2) "77"
  ["make"]=>
  string(1) "0"
  ["model"]=>
  string(0) ""
}

You can see that the last value of 'model' does not match. I believe this causes the whole method to evaluate false and then not finish removing the year from the list of garaged-vehicles.

I'd like to fix this by finding the method which adds the vehicle to the session to make sure it just pops the '0' in there, making them match. But, I wasn't able to find where that happened yet. It just needs to put in a default value. I may try to resolve this temporarily by modifying this check to be more forgiving, or perhaps update all the values before the check so that works.

In any case - hopefully there's enough information here for someone to easily resolve the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions