diff --git a/src/Producto.php b/src/Producto.php index 444cb1c..69da489 100644 --- a/src/Producto.php +++ b/src/Producto.php @@ -189,6 +189,8 @@ class Producto extends Model { unset($destacados[$i]); } } + sort($destacados); + file_put_contents($filename, json_encode($destacados)); foreach ($this->imagenes() as $imagen) { $this->deleteImagen($imagen); } @@ -221,11 +223,13 @@ class Producto extends Model { } if (!$found) { $destacados []= $this->id; - sort($destacados); $changed = true; } } - file_put_contents($filename, json_encode($destacados)); + if ($changed) { + sort($destacados); + file_put_contents($filename, json_encode($destacados)); + } } }