File tree Expand file tree Collapse file tree 3 files changed +8
-23
lines changed Expand file tree Collapse file tree 3 files changed +8
-23
lines changed Original file line number Diff line number Diff line change @@ -71,13 +71,14 @@ public function __construct(
71
71
* Initialize product instance from request data
72
72
*
73
73
* @return \Magento\Catalog\Model\Product|false
74
- * @throws NoSuchEntityException
75
74
*/
76
75
protected function _initProduct ()
77
76
{
78
77
$ productId = (int )$ this ->getRequest ()->getParam ('product ' );
79
78
if ($ productId ) {
80
- $ storeId = $ this ->_storeManager ->getStore ()->getId ();
79
+ $ storeId = $ this ->_objectManager ->get (
80
+ \Magento \Store \Model \StoreManagerInterface::class
81
+ )->getStore ()->getId ();
81
82
try {
82
83
return $ this ->productRepository ->getById ($ productId , false , $ storeId );
83
84
} catch (NoSuchEntityException $ e ) {
Original file line number Diff line number Diff line change 18
18
</div>
19
19
<!-- /ko -->
20
20
21
- <!-- ko if: messages().messages && messages().messages.length > 0 -->
22
21
<div aria-atomic="true" role="alert" class="messages" data-bind="foreach: {
23
22
data: messages().messages, as: 'message'
24
- }">
23
+ }, afterRender: purgeMessages ">
25
24
<div data-bind="attr: {
26
25
class: 'message-' + message.type + ' ' + message.type + ' message',
27
26
'data-ui-id': 'message-' + message.type
28
27
}">
29
28
<div data-bind="html: $parent.prepareMessageForHtml(message.text)"></div>
30
29
</div>
31
30
</div>
32
- <!-- /ko -->
33
31
</div>
32
+
34
33
<script type="text/x-magento-init">
35
34
{
36
35
"*": {
Original file line number Diff line number Diff line change @@ -57,27 +57,12 @@ define([
57
57
* @return {String }
58
58
*/
59
59
prepareMessageForHtml : function ( message ) {
60
- if ( ! _ . isEmpty ( this . messages ( ) . messages ) ) {
61
- this . removeMessage ( message ) ;
62
- }
63
-
64
60
return escaper . escapeHtml ( message , this . allowedTags ) ;
65
61
} ,
66
-
67
- /**
68
- * Remove provided message from message queue
69
- *
70
- * @param message
71
- */
72
- removeMessage : function ( message ) {
73
- let messages = [ ] ;
74
-
75
- for ( let i = 0 ; i < this . messages ( ) . messages . length ; i ++ ) {
76
- if ( this . messages ( ) . messages [ i ] !== message ) {
77
- messages . push ( this . messages ( ) . messages [ i ] ) ;
78
- }
62
+ purgeMessages : function ( ) {
63
+ if ( ! _ . isEmpty ( this . messages ( ) . messages ) ) {
64
+ customerData . set ( 'messages' , { } ) ;
79
65
}
80
- customerData . set ( 'messages' , messages ) ;
81
66
}
82
67
} ) ;
83
68
} ) ;
You can’t perform that action at this time.
0 commit comments