File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -177,13 +177,16 @@ protected function getProductId(): string
177
177
Visibility::VISIBILITY_BOTH
178
178
],
179
179
'in ' )
180
- ->setPageSize (10 )
180
+ ->setPageSize (1 )
181
+ ->setCurrentPage (1 )
181
182
->create ();
182
183
$ result = $ this ->productRepository ->getList ($ searchCriteria );
183
- if ($ result ->getTotalCount ()) {
184
- $ products = array_reverse ($ result ->getItems ());
185
- $ firstProduct = array_pop ($ products );
186
- $ this ->productId = (string )$ firstProduct ->getId ();
184
+ $ items = $ result ->getItems ();
185
+ $ firstProduct = reset ($ items );
186
+ if ($ firstProduct ) {
187
+ $ this ->productId = (string ) $ firstProduct ->getId ();
188
+ } else {
189
+ throw new LocalizedException (__ ("Unable to locate product to validate Recommend model. " ));
187
190
}
188
191
}
189
192
You can’t perform that action at this time.
0 commit comments