Skip to content

Commit 3888862

Browse files
committed
ACP2E-2267: The requested qty is not available message issues
- implemented different solution
1 parent 2118964 commit 3888862

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

app/code/Magento/Checkout/Controller/Cart/Add.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@ public function __construct(
7171
* Initialize product instance from request data
7272
*
7373
* @return \Magento\Catalog\Model\Product|false
74-
* @throws NoSuchEntityException
7574
*/
7675
protected function _initProduct()
7776
{
7877
$productId = (int)$this->getRequest()->getParam('product');
7978
if ($productId) {
80-
$storeId = $this->_storeManager->getStore()->getId();
79+
$storeId = $this->_objectManager->get(
80+
\Magento\Store\Model\StoreManagerInterface::class
81+
)->getStore()->getId();
8182
try {
8283
return $this->productRepository->getById($productId, false, $storeId);
8384
} catch (NoSuchEntityException $e) {

app/code/Magento/Theme/view/frontend/templates/messages.phtml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@
1818
</div>
1919
<!-- /ko -->
2020

21-
<!-- ko if: messages().messages && messages().messages.length > 0 -->
2221
<div aria-atomic="true" role="alert" class="messages" data-bind="foreach: {
2322
data: messages().messages, as: 'message'
24-
}">
23+
}, afterRender: purgeMessages">
2524
<div data-bind="attr: {
2625
class: 'message-' + message.type + ' ' + message.type + ' message',
2726
'data-ui-id': 'message-' + message.type
2827
}">
2928
<div data-bind="html: $parent.prepareMessageForHtml(message.text)"></div>
3029
</div>
3130
</div>
32-
<!-- /ko -->
3331
</div>
32+
3433
<script type="text/x-magento-init">
3534
{
3635
"*": {

app/code/Magento/Theme/view/frontend/web/js/view/messages.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,12 @@ define([
5757
* @return {String}
5858
*/
5959
prepareMessageForHtml: function (message) {
60-
if (!_.isEmpty(this.messages().messages)) {
61-
this.removeMessage(message);
62-
}
63-
6460
return escaper.escapeHtml(message, this.allowedTags);
6561
},
66-
67-
/**
68-
* Remove provided message from message queue
69-
*
70-
* @param message
71-
*/
72-
removeMessage: function (message) {
73-
let messages = [];
74-
75-
for (let i =0; i < this.messages().messages.length; i++) {
76-
if (this.messages().messages[i] !== message) {
77-
messages.push(this.messages().messages[i]);
78-
}
62+
purgeMessages: function () {
63+
if (!_.isEmpty(this.messages().messages)) {
64+
customerData.set('messages', {});
7965
}
80-
customerData.set('messages', messages);
8166
}
8267
});
8368
});

0 commit comments

Comments
 (0)