There was situation i need to add a extra page before submit rma :

on step 2 page i change the form action url like:

<form action="<?php echo $this->getStep2PostUrl(); ?>" method="POST" enctype="multipart/form-data" id="rma-form-validate" > // where action = Mage::getUrl('rma/rma/step3');

the url will redirect to the function difined in controller:
path = app/code/local/Mirasvit/Rma/controllers/RmaController.php
in rma controller you need to define a function named public function step3Action() with the following code:

public function step3Action()
    {
		if (!$this->_validateFormKey()) {
            $this->_redirectReferer();
            return;
        }
        $session = $this->_getSession();
        $formUid = $this->getRequest()->getParam('form_uid');
        if ($formUid == $session->getLastFormUid()) { //simple protection from double posting. #RMA-90
            $this->_redirectReferer();
            return;
        }
        $session->setLastFormUid($formUid);
        $customer = $session->getCustomer();
        $data = $this->getRequest()->getParams();
		$items = $data['items'];
		$rmspro = array();
		foreach($items as $k => $v) {
			$rmspro[] = $k;
		}	
		Mage::getSingleton('core/session')->setrmaitems($rmspro);
        unset($data['items']);
        try {
			$this->_redirect('*/*/stepthree', array('order' =>$this->getRequest()->getParam('order_id')));
        } catch (Mage_Core_Exception $e) {
            $session->addError($e->getMessage());
            $session->setFormData($data);
            if ($this->getRequest()->getParam('id')) {
                $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
            } else {
                $this->_redirect('*/*/add', array('order_id' => $this->getRequest()->getParam('order_id')));
            }
        }
		
	}	

in the above code in try block this will redirect to page stepthree where order id =some order id
for the stepthree page you need to write a function in Rma controller page named public function stepthreeAction() that will load the layout like:

public function stepthreeAction()
    {
      $this->loadLayout();
      $this->renderLayout();
    }

for stepthree page create a block in the following directory:
app/code/local/Mirasvit/Rma/Block/Rma/Stepthree.php
with the following code:

<?php

class Mirasvit_Rma_Block_Rma_Stepthree extends Mage_Core_Block_Template
{
    protected function _prepareLayout()
    {
        parent::_prepareLayout();
        if ($headBlock = $this->getLayout()->getBlock('head')) {
            $headBlock->setTitle(Mage::helper('rma')->__('Create RMA'));
        }
    }

    protected function getConfig()
    {
        return Mage::getSingleton('rma/config');
    }

    protected function getCustomer()
    {
        return Mage::getSingleton('customer/session')->getCustomer();
    }

    public function getOrderCollection()
    {
        return Mage::helper('rma')->getAllowedOrderCollection($this->getCustomer());
    }

    protected $_order;
    public function getOrder()
    {
        if (!$this->_order) {
            if ($orderId = Mage::app()->getRequest()->getParam('order_id')) {
                $collection = Mage::helper('rma')->getAllowedOrderCollection($this->getCustomer(), false);
                $collection->addFieldToFilter('entity_id', (int) $orderId);
                if ($collection->count()) {
                    $this->_order = $collection->getFirstItem();
                }
            }
        }

        return $this->_order;
    }

    public function getOrderItemCollection()
    {
        $order = $this->getOrder();
        $collection = $order->getItemsCollection();

        return $collection;
    }

    public function getStoreId()
    {
        return Mage::app()->getStore()->getId();
    }

    public function getReasonCollection()
    {
        return Mage::getModel('rma/reason')->getCollection()
            ->addFieldToFilter('is_active', true)
            ->setStoreId($this->getStoreId())
            ->setOrder('sort_order', 'asc');
    }

    public function getResolutionCollection()
    {
        return Mage::getModel('rma/resolution')->getCollection()
            ->addFieldToFilter('is_active', true)
            ->setOrder('sort_order', 'asc');
    }

    public function getConditionCollection()
    {
        return Mage::getModel('rma/condition')->getCollection()
            ->addFieldToFilter('is_active', true)
            ->setOrder('sort_order', 'asc');
    }

    public function getCustomFields()
    {
        $collection = Mage::helper('rma/field')->getVisibleCustomerCollection('initial', true);

        return $collection;
    }

    public function getPolicyIsActive()
    {
        return $this->getConfig()->getPolicyIsActive();
    }

    protected $_pblock;
    public function getPolicyBlock()
    {
        if (!$this->_pblock) {
            $this->_pblock = Mage::getModel('cms/block')->load($this->getConfig()->getPolicyPolicyBlock());
        }

        return $this->_pblock;
    }

    public function getPolicyTitle()
    {
        return $this->getPolicyBlock()->getTitle();
    }

    public function getPolicyContent()
    {
        $helper = Mage::helper('cms');
        $processor = $helper->getPageTemplateProcessor();

        return $processor->filter($this->getPolicyBlock()->getContent());
    }

    public function getReturnPeriod()
    {
        return $this->getConfig()->getPolicyReturnPeriod();
    }

    public function getIsGift()
    {
        return Mage::app()->getRequest()->getParam('is_gift') == 1;
    }

    public function getRmaItemsByOrderItem($orderItem)
    {
        $collection = Mage::getModel('rma/item')->getCollection();
        $collection->addFieldToFilter('order_item_id', $orderItem->getId());
        // echo $collection->getSelect();die;
        return $collection;
    }

    public function getRMAUrl($rma)
    {
        return $rma->getUrl();
    }

    public function getRmasByOrderItem($orderItem)
    {
        $result = array();
        foreach ($this->getRmaItemsByOrderItem($orderItem) as $item) {
            $rma = Mage::getModel('rma/rma')->load($item->getRmaId());
            $result[] = "<a href='{$this->getRMAUrl($rma)}' target='_blank'>#{$rma->getIncrementId()}</a>";
        }

        return implode(', ', $result);
    }
}

and in xml file ()

<rma_rma_stepthree>
        <reference name="head">
            <action method="addJs"><script>mirasvit/core/jquery.min.js</script></action>
            <action method="addJs"><script>mirasvit/core/jquery.MultiFile.js</script></action>
            <action method="addJs"><script>mirasvit/code/rma/frontend/customer.js</script></action>
        </reference>
        <update handle="customer_account"/>
        <reference name="content">
            <block type="rma/rma_stepthree" name="rma.rma.stepthree" as="rma.rma.stepthree" template="mst_rma/rma/new/step3.phtml">
            </block>
        </reference>
    </rma_rma_stepthree>

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *