Skip to content

Commit 609d0b1

Browse files
authored
ENGCOM-3715: Adding product from wishlist not adding to cart showing warning message. #19653
2 parents 994209d + d562559 commit 609d0b1

File tree

1 file changed

+34
-1
lines changed
  • app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column

1 file changed

+34
-1
lines changed

app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Cart.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
namespace Magento\Wishlist\Block\Customer\Wishlist\Item\Column;
88

9+
use Magento\Catalog\Block\Product\View;
10+
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter;
11+
use Magento\Catalog\Model\Product\Image\UrlBuilder;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\View\ConfigInterface;
14+
915
/**
1016
* Wishlist block customer item cart column
1117
*
@@ -14,6 +20,31 @@
1420
*/
1521
class Cart extends \Magento\Wishlist\Block\Customer\Wishlist\Item\Column
1622
{
23+
/**
24+
* @var View
25+
*/
26+
private $productView;
27+
28+
/**
29+
* @param \Magento\Catalog\Block\Product\Context $context
30+
* @param \Magento\Framework\App\Http\Context $httpContext
31+
* @param array $data
32+
* @param ConfigInterface|null $config
33+
* @param UrlBuilder|null $urlBuilder
34+
* @param View|null $productView
35+
*/
36+
public function __construct(
37+
\Magento\Catalog\Block\Product\Context $context,
38+
\Magento\Framework\App\Http\Context $httpContext,
39+
array $data = [],
40+
?ConfigInterface $config = null,
41+
?UrlBuilder $urlBuilder = null,
42+
?View $productView = null
43+
) {
44+
$this->productView = $productView ?: ObjectManager::getInstance()->get(View::class);
45+
parent::__construct($context, $httpContext, $data, $config, $urlBuilder);
46+
}
47+
1748
/**
1849
* Returns qty to show visually to user
1950
*
@@ -23,7 +54,9 @@ class Cart extends \Magento\Wishlist\Block\Customer\Wishlist\Item\Column
2354
public function getAddToCartQty(\Magento\Wishlist\Model\Item $item)
2455
{
2556
$qty = $item->getQty();
26-
return $qty ? $qty : 1;
57+
$qty = $qty < $this->productView->getProductDefaultQty($this->getProductItem())
58+
? $this->productView->getProductDefaultQty($this->getProductItem()) : $qty;
59+
return $qty ?: 1;
2760
}
2861

2962
/**

0 commit comments

Comments
 (0)