1

すぐに使用できる連絡先モジュールに大きく基づいて、Magento で独自のリクエスト カタログ フォームを作成しようとしています。XML ファイルをセットアップしました。

  1. ./app/etc/modules/RequestCatalog_RequestCatalog.xml
  2. ./design/frontend/default/{テーマ}/layout/requestcatalog.xml
  3. ./code/local/{名前空間}/{モジュール}/etc/config.xml

config.xml で、frontname を「requestcatalog」に設定し、モジュールのコントローラーを使用するように指示しました。ただし、http://app.com/requestcatalogにアクセスすると、次のエラーが表示されます。

致命的なエラー: 55 行目の /path/to/root/public_html/app/code/local/RequestCatalog/RequestCatalog/controllers/IndexController.php の非オブジェクトに対するメンバー関数 setFormAction() の呼び出し

IndexController.php の 55 行目は次のようになります。

$this->getLayout()->getBlock('requestcatalog')->setFormAction( Mage::getUrl('*/*/post') );

レイアウト XML で定義された「requestcatalog」という名前のブロックがあります。

私はSOを検索し、同じ問題を抱えているユーザーを見つけましたが、解決策は提供されませんでした: Magentoカスタムモジュール、致命的なエラー:メンバー関数setFormAction()への呼び出し

私のrequestcatalog.xml:

<layout version="0.1.0">
<default>
    <reference name="footer_links">
        <action method="addLink" translate="label title" module="requestcatalog" ifconfig="requestcatalog/requestcatalog/enabled"><label>Request a Catalog</label><url>requestcatalog</url><title>Request a Catalog</title><prepare>true</prepare></action>
    </reference>
</default>

<requestcatalog_index_index>
    <reference name="root">
        <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        <action method="setHeaderTitle" translate="title" module="requestcatalog"><title>Request a Catalog</title></action>
    </reference>
    <reference name="content">
        <block type="core/template" name="requestcatalog" template="requestcatalog/form.phtml"/>
    </reference>
</requestcatalog_index_index>

私のIndexAction():

   public function indexAction()
{
    $this->loadLayout();

    $this->getLayout()->getBlock('requestcatalog')
        ->setFormAction( Mage::getUrl('*/*/post') );

    $this->_initLayoutMessages('customer/session');
    $this->_initLayoutMessages('catalog/session');
    $this->renderLayout();
}
4

0 に答える 0