Take the 2-minute tour ×

I'd like to set a message that prints a confirmation for the user, i.e.:

"Thank you for deleting XYZ".

At the moment my delete() method looks like this:

public function delete($id) {
        if ($this->request->is('get')) {
            throw new MethodNotAllowedException();

        if ($this->Product->delete($id)) {
            echo "<pre>";
            echo "id: " . $id;
                    array("Product.id" => $id)
            echo "</pre>";

However, the print_r() statement shows all products, and the one delete is missing - which I assume is the right behaviour. How can I get the name of the item just deleted?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

From assumption your $id is not empty which contain some product

so you can use query like below

$product = $this->Product->find('first', array(
        'conditions' => array(
            'Product.id' => $id,
        ) ,
        'fields' => array(

so in $product['Product']['name'] you will get current product name which is you are going to delete

Please let me know if i can assist you more..

share|improve this answer
yes the ID is always valid. and this worked. thanks. –  Tamas May 4 '13 at 4:02
glad to help you.. –  liyakat May 4 '13 at 4:04
add comment

Your Answer


