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.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityWhile 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.
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.
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 checkoutSecond
*
denotes controller, in our example its IndexThird
*
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.
$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.