0

ウェブショップでのお問い合わせ用にカスタム Magento モジュールを構築しました。

以下の IndexController を参照してください。ストア ビューごとにリダイレクト ルートを変更したいと考えています。どうすればこれを達成できますか?

<?php
class MVE_ContactInquiry_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $block = $this->getLayout()->createBlock(
            'Mage_Core_Block_Template',
            'mve.contact_inquiry',
            array(
                'template' => 'mve/contact_inquiry.phtml'
            )
        );
        $this->getLayout()->getBlock('content')->append($block);
        //$this->getLayout()->getBlock('right')->insert($block, 'catalog.compare.sidebar', true);
        $this->_initLayoutMessages('core/session');
        $this->renderLayout();
    }
    public function sendemailAction()
    {

        $params = $this->getRequest()->getParams();
        $mail = new Zend_Mail();       
        $bodytext = '
            Naam: ' . $params['name'] . '
            E-mailadres: ' . $params['email'] . '
            Telefoonnummer: ' . $params['telephone'] . '
            Bericht:
            ' . $params['comment'];
        $mail->setBodyText( $bodytext );

        $mail->setFrom($params['email'], $params['name']);
        $mail->addTo('example@gmail.com');
        $mail->setSubject('Contact aanvraag');
        try {
            $mail->send();
        }
        catch(Exception $ex) {
            Mage::getSingleton('core/session')->addError('Unable to send email.');
        }

        $this->_redirect('contact/bedankt');
    }
}
?>
4

1 に答える 1

1

オプション1

/app/code/local/MVE/ContactInquiry/etc/system.xml 内

左側のナビゲーションに独自のタブを作成するとします。

<?xml version="1.0"?>
<config>
    <tabs>
        <mve_tab translate="label" module="contactinquiry">
            <label>MVE</label>
            <sort_order>900</sort_order>
        </mve_tab>
    </tabs>
    <sections>
        <contactinquiry translate="label" module="contactinquiry">
            <label>Admin Order Confirmation</label>
            <tab>mve_tab</tab>
            <sort_order>1001</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_option translate="label">
                    <label>General Options</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>
                        <redirect_url translate="label">
                            <label>URL </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>
                        </redirect_url>
                    </fields>
                </general_option>
            </groups>>
        </contactinquiry>
    </sections>
</config>

コントローラーで値を取得するには

Mage::getStoreConfig('contactinquiry/general_option/redirect_url', Mage::app()->getStore()->getId())

詳細については、管理者構成のXML を参照してください。

オプション 2

if(Mage::app()->getStore()->getStoreId() == 1){
    $this->_redirect('contact/...');
}
else if(Mage::app()->getStore()->getStoreId() == ...){
    $this->_redirect('contact/..');
}
else{
    $this->_redirect('contact/bedankt');
}

オプション 3

リダイレクト先の URL を含む各フォームに隠しフィールドを追加することもできます。

于 2012-12-06T14:59:04.477 に答える