因?yàn)楣纠镒錾坛情_發(fā)用的是OpenCart,上級(jí)讓我先熟悉這個(gè)系統(tǒng),借此機(jī)會(huì)詳細(xì)解讀一下商品管理這一功能(也是為了日后給自己加深印象)。
首先,單擊商品管理進(jìn)入商品列表后,像這樣:
上面的六個(gè)文本是用來篩選的,下面的商品列表是用來排序的;所以一個(gè)完整的url可能會(huì)包括(token:密鑰,filter_name:商品名稱,filter_model:商品型號(hào),filter_price:銷售價(jià)格,filter_quantity:商品數(shù)量,filter_status:狀態(tài),filter_category:分類,sort則為按: (商品名稱,商品型號(hào),價(jià)格,數(shù)量,狀態(tài))來排序,order:(DESC,ASC),page:分頁);
上面的panel是用來篩選條件的,像 分頁,如圖六個(gè)字段,都是通過字段名加在url后面作為參數(shù)傳遞的;因此,只要商品信息有變化,就要像這樣:
$url = '';
if (isset($this->request->get['filter_name'])) {
? $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
? $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
? $url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
? $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
? ? ? if (isset($this->request->get['filter_category'])) {
? ? ? ? ? $url .= '&filter_category=' . $this->request->get['filter_category'];
? ? ? }
? ? ? if (isset($this->request->get['filter_status'])) {
? $url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
? $url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
? $url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
? $url .= '&page=' . $this->request->get['page'];
}
因?yàn)闀?huì)刷新頁面,所以要重新組織url及url后面的參數(shù),這樣就可以:刪除某些數(shù)量商品后,還能夠保持在原有的頁數(shù)上,或是原來的篩選條件上;
在點(diǎn)了篩選按鈕后,商品列表的首頁中的js代碼首先會(huì)獲取到你在上圖六個(gè)文本中填寫的內(nèi)容,然后拼接到url上去,再location跳轉(zhuǎn)到url(其實(shí)還是商品列表首頁,只不過帶著篩選條件);
<script type="text/javascript">
$('#button-filter').on('click', function() {
? var url = 'index.php?route=catalog/product&token=<?php echo $token; ?>';
? var filter_name = $('input[name=\'filter_name\']').val();
? if (filter_name) {
? ? ? url += '&filter_name=' + encodeURIComponent(filter_name);
? }
? var filter_model = $('input[name=\'filter_model\']').val();
? if (filter_model) {
? ? ? url += '&filter_model=' + encodeURIComponent(filter_model);
? }
? var filter_price = $('input[name=\'filter_price\']').val();
? if (filter_price) {
? ? ? url += '&filter_price=' + encodeURIComponent(filter_price);
? }
? var filter_quantity = $('input[name=\'filter_quantity\']').val();
? if (filter_quantity) {
? ? ? url += '&filter_quantity=' + encodeURIComponent(filter_quantity);
? }
? var filter_status = $('select[name=\'filter_status\']').val();
? if (filter_status != '*') {
? ? ? url += '&filter_status=' + encodeURIComponent(filter_status);
? }
? ? var filter_category = $('select[name=\'filter_category\']').val();
? ? if (filter_category != '*') {
? ? ? ? url += '&filter_category=' + encodeURIComponent(filter_category);
? ? }
? location = url;
});
</script>
在跳轉(zhuǎn)頁面后,重新調(diào)用controller中的index方法加載(這里調(diào)用的getList()方法功能大概可理解為:按條件篩選遍歷獲取所有商品,加載首頁商品列表的視圖);
public function index() {
? $this->language->load('catalog/product');
? $this->document->setTitle($this->language->get('heading_title'));
? $this->load->model('catalog/product');
? $this->getList();
}
這里index中的意義為:加載語言包,設(shè)置title標(biāo)題,最重要的是先載入要進(jìn)行操作數(shù)據(jù)庫的model,再調(diào)用同controller中的getList()方法;由于controller中的getList()方法內(nèi)容實(shí)在太多,但我就要一一講解一下:)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- Start getList() --
首先,(是否點(diǎn)擊了篩選按鈕)先查看是否存在篩選條件:(不存在只要設(shè)為null即可);
if (isset($this->request->get['filter_name'])) {
? $filter_name = $this->request->get['filter_name'];
} else {
? $filter_name = null;
}
if (isset($this->request->get['filter_model'])) {
? $filter_model = $this->request->get['filter_model'];
} else {
? $filter_model = null;
}
if (isset($this->request->get['filter_price'])) {
? $filter_price = $this->request->get['filter_price'];
} else {
? $filter_price = null;
}
if (isset($this->request->get['filter_quantity'])) {
? $filter_quantity = $this->request->get['filter_quantity'];
} else {
? $filter_quantity = null;
}
if (isset($this->request->get['filter_status'])) {
? $filter_status = $this->request->get['filter_status'];
} else {
? $filter_status = null;
}
? ? ? if (isset($this->request->get['filter_category'])) {
? ? ? ? ? $filter_category = $this->request->get['filter_category'];
? ? ? } else {
? ? ? ? ? $filter_category = null;
? ? ? }
其次,(是否點(diǎn)擊了商品列表的標(biāo)題欄排序)再查看是否有排序條件:(這里默認(rèn)為按商品名稱ASC排序,第一頁);
if (isset($this->request->get['sort'])) {
? $sort = $this->request->get['sort'];
} else {
? $sort = 'pd.name';
}
if (isset($this->request->get['order'])) {
? $order = $this->request->get['order'];
} else {
? $order = 'ASC';
}
if (isset($this->request->get['page'])) {
? $page = $this->request->get['page'];
} else {
? $page = 1;
}
有了各字段后,再進(jìn)行組織url:
$url = '';
if (isset($this->request->get['filter_name'])) {
? $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
? $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
? $url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
? $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_category'])) {
? ?$url .= '&filter_category=' . $this->request->get['filter_category'];
}
if (isset($this->request->get['filter_status'])) {
? $url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
? $url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
? $url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
? $url .= '&page=' . $this->request->get['page'];
}
// urlencode():此函數(shù)便于將字符串編碼并將其用于 URL 的請(qǐng)求部分,同時(shí)它還便于將變量傳遞給下一頁。
// html_entity_decode():此函數(shù)把 HTML 實(shí)體轉(zhuǎn)換為字符。
完成之后我們就得到了一個(gè)完整的url;
接下來是面包屑導(dǎo)航:
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
? 'text' => $this->language->get('text_home'),
? 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
);
$data['breadcrumbs'][] = array(
? 'text' => $this->language->get('heading_title'),
? 'href' => $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL')
);
再是三個(gè)按鈕:新增商品,復(fù)制商品和刪除商品(這個(gè)我們稍后再講);
$data['add'] = $this->url->link('catalog/product/add', 'token=' . $this->session->data['token'] . $url, 'SSL'); ? ? ? ? ? ? ? //新增商品
$data['copy'] = $this->url->link('catalog/product/copy', 'token=' . $this->session->data['token'] . $url, 'SSL'); ? ? ? ? ? ? //復(fù)制商品
$data['delete'] = $this->url->link('catalog/product/delete', 'token=' . $this->session->data['token'] . $url, 'SSL'); ? ? ? ? //刪除商品
再是從request中獲取到的篩選條件:
$filter_data = array(
? 'filter_name' ? ?=> $filter_name, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//商品名稱
? 'filter_model' ?=> $filter_model, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//商品型號(hào)
? 'filter_price' ?=> $filter_price, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//銷售價(jià)格
? 'filter_quantity' => $filter_quantity, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //商品數(shù)量
? 'filter_status' ?=> $filter_status, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//狀態(tài)
? 'filter_category' => $filter_category, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //分類
? 'filter_is_limit' => 0, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//商品是啟用還是停用
? 'sort' ? ? ? ? ? ?=> $sort, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//排序的字段
? 'order' ? ? ? ? ?=> $order, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//ASC還是DESC
? 'start' ? ? ? ? ?=> ($page - 1) * $this->config->get('config_limit_admin'), ? ? ? ?//開始的頁數(shù)
? 'limit' ? ? ? ? ?=> $this->config->get('config_limit_admin') ? ? ? ? ? ? ? ? ? ? ? //配置文件中,一頁多少條記錄
);
然后再通過向model模型傳遞$filter_data篩選條件來獲取:符合條件的商品數(shù)量:$product_total,符合條件的商品信息:$results
model_catalog_product文件中以下兩個(gè)方法都是把篩選數(shù)據(jù)傳遞過去,然后相應(yīng)的改變sql語句即可;
$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
$results = $this->model_catalog_product->getProducts($filter_data);
再是組織商品的信息:
$data['products'] = array();
foreach ($results as $result) {
? //這之前要先$this->load->model('tool/image')加載工具類(只是調(diào)整了圖片的大小)
? if (is_file(DIR_IMAGE . $result['image'])) {
? ? ? $image = $this->model_tool_image->resize($result['image'], 40, 40);
? } else {
? ? ? $image = $this->model_tool_image->resize('no_image.png', 40, 40);
? }
? /********這里特惠商品,暫時(shí)不做介紹**********/
? $special = false;
? $product_specials = $this->model_catalog_product->getProductSpecials($result['product_id']);
? foreach ($product_specials ?as $product_special) {
? ? ? if (($product_special['date_start'] == '0000-00-00' || strtotime($product_special['date_start']) < time()) && ($product_special['date_end'] == '0000-00-00' || strtotime($product_special['date_end']) > time())) {
? ? ? ? $special = $product_special['price'];
? ? ? ? break;
? ? ? }
? }
? /********這里特惠商品,暫時(shí)不做介紹**********/
? //重新整理組織商品信息
? $data['products'][] = array(
? ? ? 'product_id' => $result['product_id'],
? ? ? 'image' ? ? ?=> $image,
? ? ? 'name' ? ? ?=> $result['name'],
? ? ? 'model' ? ? ?=> $result['model'],
? ? ? 'price' ? ? ?=> $result['price'],
? ? ? 'special' ? ?=> $special,
? ? ? 'quantity' ?=> $result['quantity'],
? ? ? 'status' ? ?=> ($result['status']) ? $this->language->get('text_enabled') : $this->language->get('text_disabled'),
? ? ? 'edit' ? ? ?=> $this->url->link('catalog/product/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'), ? ? ? ? ? //編輯商品
? ? ? 'add_limit' ?=> $this->url->link('catalog/product_limit/add', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL'),
? );
}
$data['token'] = $this->session->data['token']; ? ? ? ? ?//從session中獲取token的值
再給商品列表中的五個(gè)標(biāo)題添加鏈接(就是配置相應(yīng)的url,使得能有排序的功能):
$url = '';
if (isset($this->request->get['filter_name'])) {
? $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
? $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
? $url .= '&filter_price=' . $this->request->get['filter_price'];
}
? ? ? if (isset($this->request->get['filter_category'])) {
? ? ? ? ? $url .= '&filter_category=' . $this->request->get['filter_category'];
? ? ? }
if (isset($this->request->get['filter_quantity'])) {
? $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
? $url .= '&filter_status=' . $this->request->get['filter_status'];
}
if ($order == 'ASC') {
? $url .= '&order=DESC';
} else {
? $url .= '&order=ASC';
}
if (isset($this->request->get['page'])) {
? $url .= '&page=' . $this->request->get['page'];
}
$data['sort_name'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=pd.name' . $url, 'SSL');
$data['sort_model'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.model' . $url, 'SSL');
$data['sort_price'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.price' . $url, 'SSL');
$data['sort_quantity'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.quantity' . $url, 'SSL');
$data['sort_status'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.status' . $url, 'SSL');
$data['sort_order'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.sort_order' . $url, 'SSL');
再配置分頁功能:(配置一次就要重新組織一次url)
$url = '';
if (isset($this->request->get['filter_name'])) {
? $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
? $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
? $url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
? $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
? ? ? if (isset($this->request->get['filter_category'])) {
? ? ? ? ? $url .= '&filter_category=' . $this->request->get['filter_category'];
? ? ? }
if (isset($this->request->get['filter_status'])) {
? $url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
? $url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
? $url .= '&order=' . $this->request->get['order'];
}
$pagination = new Pagination();
$pagination->total = $product_total;
$pagination->page = $page;
$pagination->limit = $this->config->get('config_limit_admin');
$pagination->url = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
$data['pagination'] = $pagination->render(); ? ? ? ? ? ? ? //這個(gè)是分頁
$data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($product_total - $this->config->get('config_limit_admin'))) ? $product_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $product_total, ceil($product_total / $this->config->get('config_limit_admin'))); ? ? ? ? ?//這個(gè)是分頁的信息
最后再傳遞數(shù)據(jù):
/*****************若有篩選信息,則傳遞到視圖的文本框中******************/
$data['filter_name'] = $filter_name;
$data['filter_model'] = $filter_model;
$data['filter_price'] = $filter_price;
$data['filter_quantity'] = $filter_quantity;
$data['filter_status'] = $filter_status;
$data['filter_category'] = $filter_category;
/********傳遞排序的信息過去,在視圖頁面進(jìn)行判斷*********/
$data['sort'] = $sort;
$data['order'] = $order;
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
//加載視圖,傳遞數(shù)據(jù)
$this->response->setOutput($this->load->view('catalog/product_list.tpl', $data));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- END getList() --
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- Start delete() --
現(xiàn)在介紹刪除功能:
下面的商品列表看起來是一個(gè)表格,實(shí)際上外層包含了一個(gè)表單標(biāo)簽,當(dāng)你點(diǎn)擊刪除時(shí),給刪除按鈕綁定了submit()事件,提交表單到對(duì)應(yīng)的action地址上去;
注意:要?jiǎng)h除某件商品時(shí),要在那件商品前打上勾,不然就直接跳到主頁而沒有變化了;
打上勾之后就有了:
$this->request->post['selected']; ? ? ? ? ?//這是所有勾選中的商品,值為商品id
<button type="button" data-toggle="tooltip" title="<?php echo $button_delete; ?>" class="btn btn-danger" onclick="confirm('<?php echo $text_confirm; ?>') ? $('#form-product').submit() : false;"><i class="fa fa-trash-o"></i></button> ? ? ? ? ?//刪除按鈕
<form action="<?php echo $delete; ?>" method="post" enctype="multipart/form-data" id="form-product"> ? ? ? ? ?//表單標(biāo)簽
$data['delete'] = $this->url->link('catalog/product/delete', 'token=' . $this->session->data['token'] . $url, 'SSL'); ? ? //調(diào)用controller中的delete方法
進(jìn)入delete方法:
首先加載相應(yīng)的資源:(大家都知道了);
若勾選中了該商品,并且該用戶有修改的權(quán)限:
if (isset($this->request->post['selected']) && $this->validateDelete()){}
進(jìn)入if后
到數(shù)據(jù)庫中循環(huán)刪除選中的商品:
foreach ($this->request->post['selected'] as $product_id) {
? $this->model_catalog_product->deleteProduct($product_id);
}
這里再次修改或確認(rèn)$url,其功能是:刪除某些數(shù)量商品后,還能夠保持在原有的頁數(shù)上,或是原來的篩選條件上;
$url = '';
if (isset($this->request->get['filter_name'])) {
? $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_model'])) {
? $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_price'])) {
? $url .= '&filter_price=' . $this->request->get['filter_price'];
}
if (isset($this->request->get['filter_quantity'])) {
? $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
}
if (isset($this->request->get['filter_status'])) {
? $url .= '&filter_status=' . $this->request->get['filter_status'];
}
if (isset($this->request->get['sort'])) {
? $url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
? $url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
? $url .= '&page=' . $this->request->get['page'];
}
if最后,刪除成功,跳轉(zhuǎn)到商品列表首頁:
$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
if外(也就是沒有選中任何商品):
$this->getList(); ? ? ? ? ?//就跟index方法一樣,只是單純的遍歷數(shù)據(jù)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- END delete() --
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- Start add() --
下面是新增功能:
調(diào)用controller中的add方法:
$data['add'] = $this->url->link('catalog/product/add', 'token=' . $this->session->data['token'] . $url, 'SSL');
首先,加載相應(yīng)的資源;
一開始,$this->request->server['REQUEST_METHOD'] = GET,則不進(jìn)入if循環(huán),直接調(diào)用getForm()方法;
$this->getForm(); ? ? ? ? ?//加載要添加商品信息的表單
在getForm()方法中:
//首先重組url
//面包屑導(dǎo)航
//此時(shí)是加載表單的情況,因?yàn)橐晥D中<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-product" class="form-horizontal">,所以這里要判斷是add還是edit
//因?yàn)閍dd和edit方法都調(diào)用了此方法,就根據(jù)是否傳遞了id來分別
if (!isset($this->request->get['product_id'])) {
? $data['action'] = $this->url->link('catalog/product/add', 'token=' . $this->session->data['token'] . $url, 'SSL');
} else {
? $data['action'] = $this->url->link('catalog/product/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $this->request->get['product_id'] . $url, 'SSL');
}
//如果是編輯模式,則要先獲取原有的商品信息
//這里表示編輯模式
if (isset($this->request->get['product_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
? $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
}
//再是根據(jù)有無$this->request->get['product_id']或有無$product_info,來設(shè)置表單中文本框等其中的值;(add模式則為空值,edit模式則顯示數(shù)據(jù)庫中的值)
//再加載公用模板
//加載表單文件
$this->response->setOutput($this->load->view('catalog/product_form.tpl', $data));
當(dāng)$this->request->server['REQUEST_METHOD'] =POST,也就是加載的表單提交之后:
//提交表單后,并驗(yàn)證通過
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm())
//把提交的表單數(shù)據(jù)添加到數(shù)據(jù)庫
$this->model_catalog_product->addProduct($this->request->post);
//又是重整url
//提交表單,新增商品成功后,跳轉(zhuǎn)到商品列表首頁
$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -- END add() --
編輯和新增幾乎一模一樣,就不做介紹了。
其中的model文件都是sql操作,就沒有貼上來了;
本篇只是加深自己對(duì)此系統(tǒng)的認(rèn)知與記憶,希望大家多多指點(diǎn);