Professional CodeIgniter

(singke) #1

Chapter 6: Creating a Dashboard


177


Your Edit form should look like Figure 6 - 11 when all is said and done.

Figure 6-11

Creating the Product Delete Function


The product delete process will be as simple as the category delete function. Instead of actually deleting
a product (which might disrupt any number of ongoing shopping cart orders), you ’ ll opt to set a
particular product ’ s status to “ inactive. ”

Just as with the category delete() function, the product delete() function will take the fourth URI
segment as a product ID, pass that ID to a model function called deleteProduct() , and then redirect
the user to the product home page.

function delete($id){

$this- > MProducts- > deleteProduct($id);
$this- > session- > set_flashdata(‘message’,’Product deleted’);
redirect(‘admin/products/index’,’refresh’);
}
Free download pdf