File tree Expand file tree Collapse file tree 3 files changed +22
-17
lines changed
app/code/Magento/WishlistGraphQl/Model/Resolver Expand file tree Collapse file tree 3 files changed +22
-17
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ public function resolve(
88
88
$ customerId = $ context ->getUserId ();
89
89
90
90
/* Guest checking */
91
- if (! $ customerId && 0 === $ customerId ) {
91
+ if (null === $ customerId || 0 === $ customerId ) {
92
92
throw new GraphQlAuthorizationException (__ ('The current user cannot perform operations on wishlist ' ));
93
93
}
94
94
@@ -102,8 +102,8 @@ public function resolve(
102
102
$ wishlist ->loadByCustomerId ($ customerId , true );
103
103
}
104
104
105
- if (null === $ wishlist ->getId ()) {
106
- throw new GraphQlInputException (__ ('Something went wrong while creating the wishlist ' ));
105
+ if (null === $ wishlist ->getId () || $ customerId !== ( int ) $ wishlist -> getCustomerId () ) {
106
+ throw new GraphQlInputException (__ ('The wishlist was not found. ' ));
107
107
}
108
108
109
109
$ wishlistItems = [];
Original file line number Diff line number Diff line change @@ -87,20 +87,24 @@ public function resolve(
87
87
$ customerId = $ context ->getUserId ();
88
88
89
89
/* Guest checking */
90
- if (! $ customerId && 0 === $ customerId ) {
90
+ if (null === $ customerId || 0 === $ customerId ) {
91
91
throw new GraphQlAuthorizationException (__ ('The current user cannot perform operations on wishlist ' ));
92
92
}
93
93
94
- $ wishlistId = $ args ['wishlist_id ' ];
94
+ $ wishlistId = $ args ['wishlist_id ' ] ?: null ;
95
+ $ wishlist = $ this ->wishlistFactory ->create ();
95
96
96
- if (!$ wishlistId ) {
97
- throw new GraphQlInputException (__ ('The wishlist id is missing. ' ));
97
+ if ($ wishlistId ) {
98
+ $ this ->wishlistResource ->load ($ wishlist , $ wishlistId );
99
+ } elseif ($ customerId ) {
100
+ $ wishlist ->loadByCustomerId ($ customerId , true );
98
101
}
99
102
100
- $ wishlist = $ this ->wishlistFactory ->create ();
101
- $ this ->wishlistResource ->load ($ wishlist , $ wishlistId );
103
+ if ($ wishlistId ) {
104
+ $ this ->wishlistResource ->load ($ wishlist , $ wishlistId );
105
+ }
102
106
103
- if (! $ wishlist ) {
107
+ if (null === $ wishlist -> getId () || $ customerId !== ( int ) $ wishlist-> getCustomerId () ) {
104
108
throw new GraphQlInputException (__ ('The wishlist was not found. ' ));
105
109
}
106
110
Original file line number Diff line number Diff line change @@ -88,23 +88,24 @@ public function resolve(
88
88
$ customerId = $ context ->getUserId ();
89
89
90
90
/* Guest checking */
91
- if (! $ customerId && 0 === $ customerId ) {
91
+ if (null === $ customerId || 0 === $ customerId ) {
92
92
throw new GraphQlAuthorizationException (__ ('The current user cannot perform operations on wishlist ' ));
93
93
}
94
94
95
- $ wishlistId = $ args ['wishlist_id ' ];
95
+ $ wishlistId = $ args ['wishlist_id ' ] ?: null ;
96
+ $ wishlist = $ this ->wishlistFactory ->create ();
96
97
97
- if (!$ wishlistId ) {
98
- throw new GraphQlInputException (__ ('The wishlist id is missing. ' ));
98
+ if ($ wishlistId ) {
99
+ $ this ->wishlistResource ->load ($ wishlist , $ wishlistId );
100
+ } elseif ($ customerId ) {
101
+ $ wishlist ->loadByCustomerId ($ customerId , true );
99
102
}
100
103
101
- $ wishlist = $ this ->wishlistFactory ->create ();
102
-
103
104
if ($ wishlistId ) {
104
105
$ this ->wishlistResource ->load ($ wishlist , $ wishlistId );
105
106
}
106
107
107
- if (null === $ wishlist ->getId ()) {
108
+ if (null === $ wishlist ->getId () || $ customerId !== ( int ) $ wishlist -> getCustomerId () ) {
108
109
throw new GraphQlInputException (__ ('The wishlist was not found. ' ));
109
110
}
110
111
You can’t perform that action at this time.
0 commit comments