AdminHTML 주문 그리드에 고객 이메일 추가 검색 기능을 검색 할 수 있습니다.
-
12-12-2019 - |
문제
주문 그리드에 사용자 정의 전자 메일 필드를 추가하는 것과 관련된 몇 가지 질문이 있습니다.예를 들어, 이 및 이론 .
그러나 두 이들 모두 시도하고 필터링 할 때 문제가 발생합니다.주문 ID, 저장 또는 구매를 통해 검색 할 경우 새 이메일 필드를 검색 할 수 있습니다. 그런 다음 대시 보드로 이동하면 주문 그리드로 돌아가면 오류가 발생합니다.
예를 들어, 다음 코드를 사용하여 _PrepareCollection 에 합류합니다.
$collection->getSelect()->joinLeft(
array('myorder'=>'sales_flat_order'),
'myorder.entity_id = main_table.entity_id',
array('myorder.customer_email')
);
.
및 _preparecolumns에서 호출하려면 다음을 수행하십시오.
$this->addColumn('customer_email', array(
'header' => $this->helper('sales')->__('Customer Email'),
'index' => 'customer_email',
'filter_index' => 'myorder.customer_email',
));
.
이 코드에 문제가있는 아이디어는 누구입니까?
해결책
코드를 시도했는데 오류는 다음과 같습니다. "Integrity constraint 위반 : Where 절이 모호한"intruction_id '입니다.중복 된 열이 있기 때문에 일어나고 있습니다.따라서 WHERE 절을 수정하거나 간단하게 테이블을 변경해야합니다.주소 테이블을 사용하여 잘 작동합니다.
$collection->getSelect()->joinLeft(
array('oa' => 'sales_flat_order_address'),
'oa.entity_id = main_table.entity_id',
array('oa.email')
)->where("oa.address_type = 'billing'");
.
및
$this->addColumn('email', array(
'header' => $this->helper('sales')->__('Customer Email'),
'index' => 'email',
'filter_index' => 'oa.email',
));
. 제휴하지 않습니다 magento.stackexchange