You are not using the default primary key: id
. Define your primary key in your model:
class Product extends AppModel
{
public $primaryKey = 'id_producto';
}
... and assing requesting product id to id
in your controller. id
will match to primary key id_producto
in your database table:
public function ver($id = null)
{
$this->Product->id = $id;
debug($this->Product->id); //Show id with value Ex. 12,34,...;
$this->set('product', $this->Product->read());
}
Some notes:
In your controller you assign the results to plural 'products':
$this->set('products', $this->Product->read());
But in your view you use the variable in singular $product
:
Try to use <?php debug($products['Product']['nombre']); ?>
instead.