@@ -176,6 +176,7 @@ class Wishlist extends AbstractModel implements IdentityInterface
176
176
* @param DateTime $dateTime
177
177
* @param ProductRepositoryInterface $productRepository
178
178
* @param StockItemRepository $stockItemRepository
179
+ * @param ScopeConfigInterface|null $scopeConfig
179
180
* @param bool $useCurrentWebsite
180
181
* @param array $data
181
182
* @param Json|null $serializer
@@ -400,7 +401,7 @@ public function getItem($itemId)
400
401
* Adding item to wishlist
401
402
*
402
403
* @param Item $item
403
- * @return $this
404
+ * @return $this
404
405
* @throws Exception
405
406
*/
406
407
public function addItem (Item $ item )
@@ -424,7 +425,8 @@ public function addItem(Item $item)
424
425
* @return Item|string
425
426
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
426
427
* @SuppressWarnings(PHPMD.NPathComplexity)
427
- *@throws LocalizedException
428
+ * @throws LocalizedException
429
+ * @throws InvalidArgumentException
428
430
*/
429
431
public function addNewItem ($ product , $ buyRequest = null , $ forciblySetQty = false )
430
432
{
@@ -452,7 +454,8 @@ public function addNewItem($product, $buyRequest = null, $forciblySetQty = false
452
454
throw new LocalizedException (__ ('Cannot specify product. ' ));
453
455
}
454
456
455
- $ stockItem = $ this ->stockItemRepository ->get ($ product ->getId ());
457
+ /** @var \Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem */
458
+ $ stockItem = $ this ->stockItemRepository ->get ($ productId );
456
459
$ showOutOfStock = $ this ->scopeConfig ->isSetFlag (
457
460
Configuration::XML_PATH_SHOW_OUT_OF_STOCK ,
458
461
ScopeInterface::SCOPE_STORE
@@ -470,7 +473,7 @@ public function addNewItem($product, $buyRequest = null, $forciblySetQty = false
470
473
if (!is_array ($ buyRequestData )) {
471
474
$ isInvalidItemConfiguration = true ;
472
475
}
473
- } catch (InvalidArgumentException $ exception ) {
476
+ } catch (Exception $ exception ) {
474
477
$ isInvalidItemConfiguration = true ;
475
478
}
476
479
if ($ isInvalidItemConfiguration ) {
0 commit comments