2011-03-06 2 views
0

나는 옵션이 아닌 드롭 다운으로 보이도록 속성을 강요하는 방법을 찾으려고했지만 운이 없었습니다. 코드의 현재 모양은 다음과 같습니다.Magento - 속성을 변경하여 검색 목록의 드롭 다운 목록에서 선택하십시오.

case 'select': ?> 
    <div class="input-box"> <?php echo $this->getAttributeSelectElement($_attribute) ?> </div> 
    <?php endswitch; ?> 

누구나 드롭 다운 목록처럼 보이게하는 방법을 알고 있습니까? 내 영어

+0

으로

echo $this->getAttributeSelectElement($_attribute); 

를 대체? –

+0

template/catalogsearch/advanced/form.phtml – Jason

답변

0

죄송합니다 사전에

덕분에 ... 난 당신의 관리자 패널에서

;-) 프랑스어이고, 당신은

가 있는지 확인하여 속성의 유형을 선택할 수 있습니다 속성은 목록으로 선언됩니다. 내 Magento 버전에서는 코드 및 범위 뒤에있는 속성 관리 패널의 세 번째 정보입니다. PoyPoy

+0

답장을 보내 주셔서 감사합니다. 방금 두 번 확인했는데 드롭 다운으로 설정되었습니다. 왜 이런 일이 발생하는지 더 이상의 이유가 있습니까? – Jason

1

나는 오늘 아침 문제점과 같은 이상한 것은 내가의 드롭 다운 메뉴와 다른 다중 선택 메뉴를 표시하는 속성이 같은 특성 (드롭 다운)하지만 하나 있다고했다 고급 검색.

다른 설정으로 테스트를했는데 고급 검색에서 목록 (드롭 다운 및 다중 선택) 인 모든 속성이 2 개 이상의 옵션이 다중 선택으로 표시된다는 사실이 밝혀졌습니다.

나는 /app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php에 저장된 Mage_CatalogSearch_Block_Advanced_Form을보고이 조건 2가 확인 된 곳을 보았습니다. magento 핵심 팀은 '예'또는 부울 목록이 드롭 다운으로 표시되도록하기 위해 이렇게 만들었습니다. 당신이 5 번과 마지막 줄에 두 번째를 변경하는 경우,

public function getAttributeSelectElement($attribute) 
{ 
    $extra = ''; 
    $options = $attribute->getSource()->getAllOptions(false); 

    $name = $attribute->getAttributeCode(); 

    // 2 - avoid yes/no selects to be multiselects 
    if (is_array($options) && count($options)>2) { 
    . . . 

:

위에서 언급 한 파일에서

는 (마 젠토의 현재 버전에) 라인 173에서 시작하면 다음과 같은 코드 고급 검색은 옵션이 6 개 미만인 모든 속성에 드롭 다운 메뉴를 표시합니다. 나 자신은 내가 다음과 같습니다 새로운 방법, getAttributeDropDownElement(), 울부 짖는 소리 getAttributeSelectElement()를 추가를 위해 무슨 짓을

는 :

public function getAttributeDropDownElement($attribute) 
{ 
    $extra = ''; 
    $options = $attribute->getSource()->getAllOptions(false); 

    $name = $attribute->getAttributeCode(); 

    // The condition check bellow is what will make sure that every 
    // attribute will be displayed as dropdown 
    if (is_array($options)) { 
     array_unshift($options, array('value'=>'', 'label'=>Mage::helper('catalogsearch')->__('All'))); 
    } 



    return $this->_getSelectBlock() 
     ->setName($name) 
     ->setId($attribute->getAttributeCode()) 
     ->setTitle($this->getAttributeLabel($attribute)) 
     ->setExtraParams($extra) 
     ->setValue($this->getAttributeValue($attribute)) 
     ->setOptions($options) 
     ->setClass('multiselect') 
     ->getHtml(); 
} 

당신이해야 할 다음 일은 작은 경우, 내 문 속성의 이름을 검사하고 getAttributeSelectElement() 또는 새 메소드 getAttributeDropDownElement()를 호출하는 양식의 스위치 (아래 참조)를 사용하십시오. 나는이 일을 너에게 맡긴다 :

case 'select': ?> 
    <div class="input-box"> <?php echo $this->getAttributeSelectElement($_attribute) ?>  </div> 
    <?php endswitch; ?> 

희망이 있었다.

P. 제 모국어가 아닌 나쁜 영어를 사과하십시오!

0

Magento에는 Mage_Core_Block_Html_Select 클래스 (/app/code/core/Mage/Core/Block/Html/Select.php)로 사용할 수있는 선택 항목을 생성하는 클래스가 있습니다.

디자인 서식 파일 디렉터리 템플릿/catalogsearch/advanced/form에.PHTML,이에있는 파일

echo $this->getLayout()->createBlock('core/html_select') 
        ->setOptions($_attribute->getSource()->getAllOptions(true)) 
        ->setName($_attribute->getAttributeCode()) 
        ->setClass('select') 
        ->setId($_attribute->getAttributeCode()) 
        ->setTitle($this->getAttributeLabel($_attribute)) 
        ->getHtml(); 
관련 문제