2022-08-23 10:43:06 - 米境通跨境電商
因?yàn)楣纠镒錾坛情_發(fā)用的是OpenCart,上級(jí)讓我先熟悉這個(gè)系統(tǒng),借此機(jī)會(huì)詳細(xì)解讀一下商品管理這一功能(也是為了日后給自己加深印象)。
首先,單擊商品管理進(jìn)入商品列表后,像這樣:
商品列表界面
上面的六個(gè)文本是用來(lái)篩選的,下面的商品列表是用來(lái)排序的;所以一個(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))來(lái)排序,order:(DESC,ASC),page:分頁(yè));
上面的panel是用來(lái)篩選條件的,像分頁(yè),如圖六個(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ì)刷新頁(yè)面,所以要重新組織url及url后面的參數(shù),這樣就可以:刪除某些數(shù)量商品后,還能夠保持在原有的頁(yè)數(shù)上,或是原來(lái)的篩選條件上;
在點(diǎn)了篩選按鈕后,商品列表的首頁(yè)中的js代碼首先會(huì)獲取到你在上圖六個(gè)文本中填寫的內(nèi)容,然后拼接到url上去,再location跳轉(zhuǎn)到url(其實(shí)還是商品列表首頁(yè),只不過帶著篩選條件);