Mage :: getStoreConfig ()와 getConfigData ()의 차이점은 무엇입니까?


10

차이점이 무엇인지 설명해주세요

$this->getConfigData('xyz')그리고 Mage::getStoreConfig('abc/xyz/hfc').

두 기능의 차이점은 무엇입니까?

답변:


16

사용하는 Mage::getStoreConfig('abc/xyz/hfc')경우 섹션 이름, 탭 이름 및 필드 이름을 전달해야합니다. 해당 필드의 값을 가져옵니다.

그러나 지불 모듈이 있고 100 개 이상의 필드가 있다고 가정하면 전체 경로를 제공 할 수 없습니다. 모듈에서 아래와 같이 한 가지 방법을 만들 수 있습니다. 따라서 키를 전달하면 기능을 사용하여 경로가 생성됩니다.

public function getConfigData($key)
{
    return Mage::getStoreConfig("catalog/custom_options/$key");
}

쉽게 식별 할 수 있습니다.

마 젠토에서 Release Notes그들은 또한이 라인을 언급Made fetching payment methods sort order properly: via getConfigData() rather getStoreConfig() (optimization for 3rd-party customizations).


좋은 직업 @Keyul
Amit Bera

1

Mage::getStoreConfig() 시스템 입력 관리자에서 특정 필드를 저장하는 데 사용합니다.

getStoreConfig(),Magento는 특정 저장소 개체의 인스턴스에 대한 참조를 가져옵니다. getStore가 반환합니다 an instance of the current store object.

http://alanstorm.com/magento_loading_config_variables를 참조하십시오

/programming/5892476/how-to-get-data-from-magento-system-configuration

/programming/19941411/magento-getstoreconfig-multistore

그리고 getConfigData()일반적으로주는 Current Class의 기능current store configuration value


0

Keyul Shah의 답변에 추가 : Mage :: getStoreConfig ( 'abc / xyz / hfc')에서 얻을 수있는 값은 magento DB의 core_config_data 테이블에 저장됩니다. 이 함수는 무엇이든 반환하기 전에 core_config_data 테이블의 'path'열에 항목이 있어야합니다. core_config_data에는 store_id에 대한 열이 있습니다. 상점 ID가 인수로 전달되지 않으면 admin에 속하는 기본 상점 ID 0이 사용됩니다.


0

공용 함수 getConfigData ($ key) {return Mage :: getStoreConfig ( "catalog / custom_options / $ key"); }

html.php 파일에서 위의 코드를 제거했습니다. 코드를 제거한 후 다른 코드 나 데이터베이스를 확인해야합니까?

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.