2014-09-22 3 views
0

내가 Catelog에서 "필터"라는 카테고리 속성 만든 - 카테고리 :magento에서 카테고리 속성을 업데이트하는 방법은 무엇입니까?

<?php 
$this->startSetup(); 
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'filter', array(
    'group'   => 'General Information', 
    'input'   => 'select', 
    'type'   => 'varchar', 
    'label'   => 'Filter', 
    'backend'  => '', 
    'visible'  => true, 
    'required'  => false, 
    'visible_on_front' => true, 
    'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
    )); 
$this->endSetup(); 

을 그리고 지금 내가 온라인으로 검색하고 코드를 작성하려고,이 속성에 "예/아니오"를 추가하려면, 하지만 그들은 작동하지 않습니다 :

<?php 
$add = $this->getEntityTypedId('catalog_category'); 
$this->updateAttribute($add, 'Filter', array(
    'option'  =>array('value' => array('optionone' => array('Yes'), 
              'optiontwo' => array('No'), 
              ) 
          ) 
              ) 
        ); 

제게 몇 가지 힌트를 주셔서 감사합니다!

답변

0

사용 소스 모델

$this->startSetup(); 
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'filter', array(
    'group'   => 'General Information', 
    'input'   => 'select', 
    'type'   => 'varchar', 
    'label'   => 'Filter', 
'backend'  => '', 
'visible'  => true, 
'required'  => false, 
'visible_on_front' => true, 
'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
'source'  => 'artic_filter/filter', 
)); 

$this->endSetup(); 

지금 클래스를 만들 수 있습니다.

class Namespace_Module_Model_Source_Filter extends Mage_Eav_Model_Entity_Attribute_Source_Table { 

공용 기능 getAllOptions()
{ 창 어레이 ( 'optionone'=> '옵션 1' 'optiontwo'=> '옵션 2' ) } }

업데이트 : 이 태그를 xml

+0

저는 magento를 처음 사용하기 때문에 귀하의 답변에 대해 몇 가지 질문이 있습니다. 'source'부분은 생성 된 클래스 "Namespace_Module_Model_Source_Filter"의 경로이고 파일 이름은 "source_filter"입니다.이 파일을 수정할 수 있습니다. 맞습니까? 감사! –

+0

답변을 시도했지만 백엔드에는 변경 사항이 없습니다. 내가 설치 스크립트에 " '소스'\t => 'Filter_Model/updateFilter를',"추가하고이 같은 클래스를 만들 : 'Yes', 'optiontwo'=> 'No'); \t}} –

+0

설정 파일 – user773440

관련 문제