2017-02-04 2 views
0

Я пытаюсь написать свое первое расширение для magento. Поэтому я расскажу о некоторых учебниках, чтобы понять это.Расширение бэкэнда Magento не удалось открыть поток: нет такого файла или каталога

Однако у меня возникла проблема с отображением некоторых параметров в конфигурации бэкэнд.

Мой каталог выглядит следующим образом

--R2retail 
    /--HelloWorldTut 
    /--Block 
    /--controllers 
    /--etc 
     /--config.xml 
     /--system.xml 
    /--Helper 
     /--Data.php 
    /--Model 
     /--Options.php 
    /--sql 

Я перечислил только те файлы, которые имеют отношение здесь.

Мой R2retail_HelloWorldTut файл, который находится в /app/etc/modules/ выглядит следующим образом

<?xml version="1.0"?> 
    <config> 
     <modules> 
     <R2retail_HelloWorldTut> 
      <active>true</active> 
      <codePool>local</codePool> 
     </R2retail_HelloWorldTut> 
     </modules> 
    </config> 

мой config.xml выглядит следующим образом

<?xml version="1.0"?> 
    <config> 
    <modules> 
     <R2retail_HelloWorldTut> 
      <version>0.1.0</version> 
     </R2retail_HelloWorldTut> 
    </modules> 
    <global> 
     <helpers> 
      <helloworldtut> 
      <class>R2retail_HelloWorldTut_Helper</class> 
      </helloworldtut> 
     </helpers> 
     <models> 
      <class>R2retail_HelloWorldTut_Model</class> 
     </models> 
    </global> 
    <frontend> 
     <routers> 
      <helloworldtut> 
       <use>standard</use> 
       <args> 
       <module>R2retail_HelloWorldTut</module> 
       <frontName>helloworld</frontName> 
       </args> 
      </helloworldtut> 
     </routers> 
    </frontend> 
    <adminhtml> 
     <acl> 
     <resources> 
      <admin> 
      <children> 
       <config> 
       <children> 
        <helloworldtut_options> 
        <title>R2retail Modules</title> 
        </helloworldtut_options> 
       </children> 
       </config> 
      </children> 
      </admin> 
     </resources> 
     </acl> 
    </adminhtml> 
</config> 

Мои system.xml выглядит следующим образом (я подозреваю, что ошибка где-то здесь)

<?xml version="1.0"?> 
<config> 
    <tabs> 
     <helloworldtut translate="label" module="helloworldtut"> 
      <label>Custom Configuration Tab</label> 
      <sort_order>1</sort_order> 
     </helloworldtut> 
    </tabs> 

    <sections> 
     <helloworldtut_options translate="label" module="helloworldtut"> 
      <label>Custom Configuration Settings</label> 
      <tab>helloworldtut</tab> 
      <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> 
      <groups> 
       <section_one translate="label"> 
        <label>Section One</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> 
        <fields> 
         <custom_field_one> 
          <label>Custom Text Field</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> 
          <comment>Example of text field.</comment> 
         </custom_field_one> 
        </fields> 
       </section_one> 
       <secttion_two translate="label"> 
        <label>Section Two</label> 
        <frontend_type>text</frontend_type> 
        <sort_order>2</sort_order> 
        <show_in_default>1</show_in_default> 
        <show_in_website>1</show_in_website> 
        <show_in_store>1</show_in_store> 
        <fields> 
         <custom_field_two> 
          <label>Custom Select Field</label> 
          <frontend_type>select</frontend_type> 
          <source_model>helloworldtut/options</source_model> 
          <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> 
          <comment>Example of select field.</comment> 
         </custom_field_two> 
         <custom_field_three> 
          <label>Custom Radio Field</label> 
          <frontend_type>radios</frontend_type> 
          <source_model>helloworldtut/options</source_model> 
          <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> 
          <comment>Example of Radio Buttons</comment> 
         </custom_field_three> 
         <custom_field_four> 
          <label>Custom Multiselect Field</label> 
          <frontend_type>multiselect</frontend_type> 
          <source_model>helloworldtut/options</source_model> 
          <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> 
          <comments>Example of Multiselect field</comments> 
         </custom_field_four> 
        </fields> 
       </secttion_two> 
      </groups> 
     </helloworldtut_options> 
    </sections> 
</config> 

Когда я прокомментирую второй раздел. страница конфигурации загружается без каких-либо проблем. так что идет не так, как только я <source_model>helloworldtut/options</source_model>

Мои Data.php выглядит следующим образом

<?php 
/** 
* Sample Widget Helper 
*/ 
class R2retail_HelloWorldTut_Helper_Data extends Mage_Core_Helper_Abstract 
{ 
} 

и, наконец, мой Options.php выглядит следующим образом

<?php 
class R2retail_HelloWorldTut_Model_Options { 
    /** 
    * Provide available options as a value/label array 
    * 
    * @return array 
    */ 
    public function toOptionArray() 
    { 
    return array(
     array('value'=>1, 'label'=>'One'), 
     array('value'=>2, 'label'=>'Two'), 
     array('value'=>3, 'label'=>'Three'),    
     array('value'=>4, 'label'=>'Four')      
    ); 
    } 
} 

Я надеюсь, что кто-то может помочь мне понять, где я Неправильно

ответ

1

Я не тестировал ваш код, но вы, вероятно, прав насчет исходной модели, вызывающей probl Эм.

Вы ссылаетесь на модель псевдоним:

<source_model>helloworldtut/options</source_model> 

Однако псевдоним не определен - возможно, вы ринулись через определения модели немного слишком быстро?

<models> 
    <class>R2retail_HelloWorldTut_Model</class> 
</models> 

должен иметь псевдоним:

<models> 
    <helloworldtut> 
     <class>R2retail_HelloWorldTut_Model</class> 
    </helloworldtut> 
</models> 
+0

я отправил его в стек Magento, а также и уже получил ответ там. Но это была ошибка, которую я сделал. Я даже не уверен, как я пропустил это, чтобы начать с этого. – NoSixties

Смежные вопросы