문제

일부 조인이있는 Varien_Db_Select 객체가 있고 그 중 하나에서 조건을 변경해야합니다.어떻게해야합니까?

업데이트 : "부터"부터 "Joincondition"부분에있는 상태를 발견했습니다.나는 반복 할 수 있지만, 나는 그들을 다시 넣을 수 없다

도움이 되었습니까?

해결책

그래서 이것이 내가 일어난 일입니다 :

$fromAndJoins = $select->getPart(Zend_Db_Select::FROM);
foreach($fromAndJoins as $key=>$joins){
        if(strpos($joins['joinCondition'],$attribute->getAttributeCode().'_idx.attribute_id')!==false){
            $newcondition = //change $joins['joinCondition'] as you want
            $fromAndJoins[$key]['joinCondition']=$newcondition;

        }
    }
$select->reset(Zend_Db_Select::FROM);
$select->setPart(Zend_Db_Select::FROM,$fromAndJoins);
.

다른 팁

여기에 내가 사용할 방법이 있습니다.

다음과 같이 조건 ( "부분)을 얻을 수 있습니다.

$where = $collection->getSelect()->getPart('where');
.

다음과 같은 조건을 반복 할 수 있습니다.

foreach ($where as $key => $condition)
{
// Do what you need
}
.

마지막으로 변경 사항을 변경하면 업데이트 된 조건을 컬렉션에 적용하는 것을 잊지 마십시오.

$collection->getSelect()->setPart('where', $where);
.

오류가 발생하면

상관 관계 이름 'xxx'를 한번 이상 정의 할 수 없음

키가 내 경우에있는 키가있는 unset($fromAndJoins[$key]); 항목을 사용해야합니다

$key = $attribute->getAttributeCode().'_idx.attribute_id';
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top