2016-12-05 1 views
0

Prestashop 1.6에서 모듈에 대한 사용자 지정 목록을 만들려고하고 있으며 세 가지 테이블에서 데이터를 가져와야합니다. 내 문제는 $this->_filter 변수입니다. 어떻게 할 수 있습니까?Prestashop 1.6 용 필터

나는이 작업을 수행해야합니다

public function getCustomListHostessGifts() { 
    $this->table = 'scd_gift'; 
    $this->list_id = 'hostess_gift'; 
    $this->lang = true; 
    $this->identifier = 'id_scd_gift'; 
    $this->_orderBy = 'id_product'; 
    $this->_orderWay = 'DESC'; 

    $this->addRowAction('delete'); 

    $this->fields_list = (array(
     'id_product' => array('title' => $this->l('ID'), 'class' => 'fixed-width-xs', 
           'align' => 'center'), 
     'name' => array('title' => $this->l('Name'), 'filter_key' => 'b!name'), 
    )); 

    $this->clearFilters(); 

    $hostessType = MlmGiftsModule::getGiftTypeIdByGiftTypeName('_HOSTESSGIFT_'); 

    $this->_join = Shop::addSqlAssociation('scd_gift', 'a'); 

    $this->_filter = ' 
     INNER JOIN '._DB_PREFIX_.'product_lang pl 
       ON s.id_product = pl.id_product 
       AND a.`id_gift_type` ='.$hostessType ; 

    $this->toolbar_title = $this->l('Hostess gifts:'); 

    return $this->renderList(); 
} 

답변

0

_filter 백 오피스 목록 검색 필드에서 통과 필터 매개 변수를 설정하는 데 사용은 다음과 같습니다

$query = ' 
SELECT s.*, pl.* 
FROM '._DB_PREFIX_.'`scd_gift` s 
INNER JOIN '._DB_PREFIX_.'product_lang pl 
ON s.id_product = pl.id_product 
WHERE s.`id_gift_type` = '.(int)$id_gift_type.' and id_lang='.$id_lang; 

것은 여기 내 기능입니다. 모든 JOIN 문장 _join VAR에 설정해야합니다

$this->_join = Shop::addSqlAssociation('scd_gift', 'a'); 
     . ' INNER JOIN '._DB_PREFIX_.'product_lang pl 
       ON s.id_product = pl.id_product 
       AND a.`id_gift_type` ='.$hostessType ; 

행운을 빕니다.

0

PixelWeb의 대답은 정확하지만 물론,

$this->_join = Shop::addSqlAssociation('scd_gift', 'a') 

추가 후 세미콜론이 없습니다. Prestashop은 컨트롤러의 테이블에 대한 기본 SQL 연결 "a"를 추가하기 때문에이 줄을 건너 뛸 수 있습니다.

관련 문제