4

While I'm studying a line of code in magento vendor file I found this code:

$resultRedirect->setPath('*/*/');

What does this '*/*/' means and where does this redirects. Hope I will get more clarification.

  • On which controller file you get this? – Sukumar Gorai Nov 26 '18 at 11:34
9

If you need to know detail about the following code then read the following:

$resultRedirect->setPath('*/*/');

First * means current route and second * means current controller. Let me explain it in detail with example.

Suppose you are submitting any form to http://example.com/someroute/somecontroller/someaction. Then in this case if you are using $resultRedirect->setPath('*/*/'); then it will redirect you to current route and current controller like http://example.com/someroute/somecontroller/index. Index action is here because if you have not mentioned any action $resultRedirect->setPath('*/*/');.

Suppose you are submitting any form to http://example.com/someroute/somecontroller/someaction. Then in this case if you are using $resultRedirect->setPath('*/*/test'); then it will redirect you to current route and current controller like http://example.com/someroute/somecontroller/test. Test action is here because if you have not mentioned any action $resultRedirect->setPath('*/*/test');.

Summary: First * for route, second * for controller and third for action.

| improve this answer | |
5

It is used to redirect current route, current controller's index action.

Let say if you are currently browsing

checkout/index/customaction

if you are using this code in custom action controller, then it will redirect you to checkout/index/index So in this case

checkout/index/index = '*/*/' OR '*/*/Index' (both are same);

here

First * denotes current route, in our example its checkout

Second * denotes controller, in our example its Index

Third * denotes action (if available otherwise Index by default)

if you use

'*/*/test'

Then in our example it will redirect you to checkout/index/test.

'*/*/*' means current action

Also we can say that '*/*' will redirect you to the current module's index controller

I hope you got idea on it.

| improve this answer | |
3
 $resultRedirect->setPath('*/*/');

This will redirect you to the current module's index controller. For example you are on customer/account/create controller then If I write this line of code in controller it'll take you to customer/account/index controller.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.