@@ -40,19 +40,9 @@ class MassUpdateProductAttribute
40
40
private $ stockConfiguration ;
41
41
42
42
/**
43
- * @var \Magento\Framework\App\RequestInterface
43
+ * @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute
44
44
*/
45
- private $ request ;
46
-
47
- /**
48
- * @var \Magento\Backend\Model\Session
49
- */
50
- private $ session ;
51
-
52
- /**
53
- * @var \Magento\Store\Model\StoreManagerInterface
54
- */
55
- private $ storeManager ;
45
+ private $ attributeHelper ;
56
46
57
47
/**
58
48
* @var \Magento\Backend\Model\View\Result\Redirect
@@ -69,9 +59,7 @@ class MassUpdateProductAttribute
69
59
* @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
70
60
* @param \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository
71
61
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration
72
- * @param \Magento\Framework\App\RequestInterface $request
73
- * @param \Magento\Backend\Model\Session $session
74
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
62
+ * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper
75
63
* @param \Magento\Backend\Model\View\Result\RedirectFactory $redirectFactory
76
64
* @param \Magento\Framework\Message\ManagerInterface $messageManager
77
65
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -82,9 +70,7 @@ public function __construct(
82
70
\Magento \CatalogInventory \Api \StockRegistryInterface $ stockRegistry ,
83
71
\Magento \CatalogInventory \Api \StockItemRepositoryInterface $ stockItemRepository ,
84
72
\Magento \CatalogInventory \Api \StockConfigurationInterface $ stockConfiguration ,
85
- \Magento \Framework \App \RequestInterface $ request ,
86
- \Magento \Backend \Model \Session $ session ,
87
- \Magento \Store \Model \StoreManagerInterface $ storeManager ,
73
+ \Magento \Catalog \Helper \Product \Edit \Action \Attribute $ attributeHelper ,
88
74
\Magento \Backend \Model \View \Result \RedirectFactory $ redirectFactory ,
89
75
\Magento \Framework \Message \ManagerInterface $ messageManager
90
76
) {
@@ -93,9 +79,7 @@ public function __construct(
93
79
$ this ->stockRegistry = $ stockRegistry ;
94
80
$ this ->stockItemRepository = $ stockItemRepository ;
95
81
$ this ->stockConfiguration = $ stockConfiguration ;
96
- $ this ->request = $ request ;
97
- $ this ->session = $ session ;
98
- $ this ->storeManager = $ storeManager ;
82
+ $ this ->attributeHelper = $ attributeHelper ;
99
83
$ this ->redirectFactory = $ redirectFactory ;
100
84
$ this ->messageManager = $ messageManager ;
101
85
}
@@ -107,18 +91,19 @@ public function __construct(
107
91
* @param callable $proceed
108
92
*
109
93
* @return \Magento\Framework\Controller\ResultInterface
110
- *
111
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
112
94
*/
113
95
public function aroundExecute (Save $ subject , callable $ proceed )
114
96
{
115
97
try {
116
- $ inventoryData = $ this ->request ->getParam ('inventory ' , []);
117
- $ storeId = $ this ->request ->getParam ('store ' , \Magento \Store \Model \Store::DEFAULT_STORE_ID );
118
- $ websiteId = $ this ->storeManager ->getStore ($ storeId )->getWebsiteId ();
119
- $ productIds = $ this ->session ->getData ('product_ids ' );
98
+ /** @var \Magento\Framework\App\RequestInterface $request */
99
+ $ request = $ subject ->getRequest ();
100
+ $ inventoryData = $ request ->getParam ('inventory ' , []);
120
101
$ inventoryData = $ this ->addConfigSettings ($ inventoryData );
121
102
103
+ $ storeId = $ this ->attributeHelper ->getSelectedStoreId ();
104
+ $ websiteId = $ this ->attributeHelper ->getStoreWebsiteId ($ storeId );
105
+ $ productIds = $ this ->attributeHelper ->getProductIds ();
106
+
122
107
if (!empty ($ inventoryData )) {
123
108
$ this ->updateInventoryInProducts ($ productIds , $ websiteId , $ inventoryData );
124
109
}
0 commit comments