12
12
use Magento \Framework \App \Action \HttpPostActionInterface ;
13
13
use Magento \Framework \Controller \Result \Redirect ;
14
14
use Magento \Framework \Data \Form \FormKey \Validator ;
15
+ use Magento \Framework \DataObject ;
15
16
use Magento \Framework \Exception \LocalizedException ;
16
17
use Magento \Framework \Exception \NotFoundException ;
17
18
use Magento \Framework \Exception \NoSuchEntityException ;
@@ -101,7 +102,9 @@ public function execute()
101
102
/** @var Redirect $resultRedirect */
102
103
$ resultRedirect = $ this ->resultFactory ->create (ResultFactory::TYPE_REDIRECT );
103
104
$ session = $ this ->_customerSession ;
104
- $ requestParams = $ this ->getRequest ()->getParams ();
105
+ $ data = empty ($ session ->getBeforeWishlistUrl ())
106
+ ? $ this ->getRequest ()->getParams ()
107
+ : $ session ->getBeforeRequestParams ();
105
108
if (!$ this ->formKeyValidator ->validate ($ this ->getRequest ())) {
106
109
return $ resultRedirect ->setPath ('*/ ' );
107
110
}
@@ -111,7 +114,7 @@ public function execute()
111
114
throw new NotFoundException (__ ('Page not found. ' ));
112
115
}
113
116
114
- $ productId = isset ($ requestParams ['product ' ]) ? (int )$ requestParams ['product ' ] : null ;
117
+ $ productId = isset ($ data ['product ' ]) ? (int )$ data ['product ' ] : null ;
115
118
if (!$ productId ) {
116
119
$ resultRedirect ->setPath ('*/ ' );
117
120
return $ resultRedirect ;
@@ -130,7 +133,7 @@ public function execute()
130
133
}
131
134
132
135
try {
133
- $ buyRequest = new \ Magento \ Framework \ DataObject ($ requestParams );
136
+ $ buyRequest = new DataObject ($ data );
134
137
135
138
$ result = $ wishlist ->addNewItem ($ product , $ buyRequest , true );
136
139
if (is_string ($ result )) {
0 commit comments