2013-02-14 1 views
2

먼저 Magento vernacular와 관련하여 실수를하면 플랫폼에 대한 첫 번째 프로젝트입니다.로컬 XML이 Magento 확장의 기본 구성보다 우선 함

밤마다 동일한 서버에있는 FTP 사이트에서 데이터를 가져 오는 Magento 1.7 용 확장 프로그램에서 작업하고 있습니다. 오히려 하드 코드보다 내가 응용 프로그램/코드 /에 다음을 추가 한 내 모듈에 FTP 디렉토리 경로 지역/회사 명/모듈 이름을/etc/config.xml에 :

<?xml version="1.0" encoding="UTF-8"?> 
<config> 
    <default> 
    <ftp_server_path>/home/ftpuser/</ftp_server_path> 
    </default> 
    ... other module configuration... 
</config> 

내가 접근 할 수 있어요 내 모델의이 저장된 값은 Mage::getStoreConfig('ftp_server_path')입니다.

이제는 환경 단위 (내 로컬 컴퓨터, 준비 등)에 ftp_server_path 값을 무시하고 싶습니다. 내 첫 번째 생각은 app/etc/local.xml 이었지만 적절한 위치인지 확실하지 않고 b) app/etc/local.xml에 환경 관련 확장 구성이 저장되어있는 좋은 예를 찾을 수 없었다.

이 문제에 관해 제공 할 수있는 지침은 크게 감사하겠습니다. 미리 감사드립니다.

답변

3

왜 system.xml 파일을 사용하여이 ftp 경로를 백엔드의 편집 가능 필드에있는 데이터베이스에 저장할 수 없습니까?

그러면 로컬/dev/live 버전을 갖기 위해 각 백엔드에서이를 변경해야합니다.

하면 모듈의 etc 디렉토리에있는 system.xml을 파일을 만들고이를 넣어 :

<?xml version="1.0"?> 
<config> 
<sections> 
    <ftppath translate="label" module="yourmodule"> 
     <label>Manage </label> 
     <tab>general</tab> 
     <sort_order>50</sort_order> 
     <show_in_default>1</show_in_default> 
     <show_in_website>1</show_in_website> 
     <show_in_store>1</show_in_store> 
     <groups> 
      <general translate="label"> 
       <label>General</label> 
       <frontend_type>text</frontend_type> 
       <sort_order>10</sort_order> 
       <show_in_default>1</show_in_default> 
       <show_in_website>1</show_in_website> 
       <show_in_store>1</show_in_store> 
       <fields> 
        <path translate="label"> 
         <label>Path to FTP Server</label> 
         <frontend_type>text</frontend_type> 
         <sort_order>1</sort_order> 
         <show_in_default>1</show_in_default> 
         <show_in_website>1</show_in_website> 
         <show_in_store>1</show_in_store> 
        </path> 
       </fields> 
      </general> 
     </groups> 
    </ftppath> 
</sections> 

당신은 ('ftppath/일반/경로 마법사 :: getStoreConfig을 수행하여이 값을 얻을 수 있습니다 ');

당신은

<?xml version="1.0" encoding="UTF-8"?> 
<config> 
<acl> 
    <resources> 
     <admin> 
      <children> 
       <system> 
        <children> 
         <config> 
          <children> 
           <ftppath translate="title" module="yourmodule"> 
            <title>Manage FTP</title> 
            <sort_order>50</sort_order> 
           </ftppath> 
          </children> 
         </config> 
        </children> 
       </system> 
      </children> 
     </admin> 
    </resources> 
</acl> 

PS 만 ​​특정 사용자 그룹의 관리자에 의해 볼 수 있습니다 (모듈의 etc 디렉토리에 계속)를 adminhtml.xml 파일에 ACL을 만들려면이 섹션이 필요한 경우 : 나는 app/etc/local.xml 파일에서 작동하는 것과 비슷한 것을 만들었지 만 1.7 이후에는 더 이상 작동하지 않습니다. (

+1

에 있지만 답변과 [앨런 스톰의 (오래된) 제 (사이 저를 도와 또 다른 링크 http://alanstorm.com/ custom_magento_system_configuration) 나는 그것을 작동시킬 수 있었다. 도와 줘서 고마워! –

1

허용 된 SO 대답의 정보는 아주 좋은 출발점 임에도 불구하고 부족합니다 커스텀 설정을 추가하기 위해 필요한 많은 것들 이온.

@SteveGrunwell (here) 님이 수락 한 답변의 기사가 조금 구식이긴해도 그게 작동되도록하는 데는 도움이되었습니다. 그것은 매우 상세하고 요점입니다.

오래된 버전은 버전 1.4 이상에서 ACL 부분이 모듈의/etc/폴더에있는 adminhtml.xml 파일에 있다고 가정합니다.

내가 백엔드를 통해이 편집을하는 것은 복잡 할 것이라고 걱정했다 magento site