Skip to content

Commit 9cb874f

Browse files
authored
Merge pull request #3545 from magento-tsg-csl3/2.3-develop-pr13
[TSG-CSL3] For 2.3 (pr13)
2 parents 25fb501 + 3a88db7 commit 9cb874f

File tree

16 files changed

+566
-38
lines changed

16 files changed

+566
-38
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Category.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,20 @@ public function getProductsPosition($category)
486486
$this->getCategoryProductTable(),
487487
['product_id', 'position']
488488
)->where(
489-
'category_id = :category_id'
489+
"{$this->getTable('catalog_category_product')}.category_id = ?",
490+
$category->getId()
490491
);
492+
$websiteId = $category->getStore()->getWebsiteId();
493+
if ($websiteId) {
494+
$select->join(
495+
['product_website' => $this->getTable('catalog_product_website')],
496+
"product_website.product_id = {$this->getTable('catalog_category_product')}.product_id",
497+
[]
498+
)->where(
499+
'product_website.website_id = ?',
500+
$websiteId
501+
);
502+
}
491503
$bind = ['category_id' => (int)$category->getId()];
492504

493505
return $this->getConnection()->fetchPairs($select, $bind);

app/code/Magento/Catalog/Model/ResourceModel/Category/Flat.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,20 @@ public function getProductsPosition($category)
699699
$this->getTable('catalog_category_product'),
700700
['product_id', 'position']
701701
)->where(
702-
'category_id = :category_id'
702+
"{$this->getTable('catalog_category_product')}.category_id = ?",
703+
$category->getId()
703704
);
705+
$websiteId = $category->getStore()->getWebsiteId();
706+
if ($websiteId) {
707+
$select->join(
708+
['product_website' => $this->getTable('catalog_product_website')],
709+
"product_website.product_id = {$this->getTable('catalog_category_product')}.product_id",
710+
[]
711+
)->where(
712+
'product_website.website_id = ?',
713+
$websiteId
714+
);
715+
}
704716
$bind = ['category_id' => (int)$category->getId()];
705717

706718
return $this->getConnection()->fetchPairs($select, $bind);

app/code/Magento/Checkout/Model/DefaultConfigProvider.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,12 @@ public function getConfig()
282282
$quote = $this->checkoutSession->getQuote();
283283
$quoteId = $quote->getId();
284284
$email = $quote->getShippingAddress()->getEmail();
285+
$quoteItemData = $this->getQuoteItemData();
285286
$output['formKey'] = $this->formKey->getFormKey();
286287
$output['customerData'] = $this->getCustomerData();
287288
$output['quoteData'] = $this->getQuoteData();
288-
$output['quoteItemData'] = $this->getQuoteItemData();
289+
$output['quoteItemData'] = $quoteItemData;
290+
$output['quoteMessages'] = $this->getQuoteItemsMessages($quoteItemData);
289291
$output['isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
290292
$output['selectedShippingMethod'] = $this->getSelectedShippingMethod();
291293
if ($email && !$this->isCustomerLoggedIn()) {
@@ -316,6 +318,7 @@ public function getConfig()
316318
);
317319
$output['postCodes'] = $this->postCodesConfig->getPostCodes();
318320
$output['imageData'] = $this->imageProvider->getImages($quoteId);
321+
319322
$output['totalsData'] = $this->getTotalsData();
320323
$output['shippingPolicy'] = [
321324
'isEnabled' => $this->scopeConfig->isSetFlag(
@@ -450,6 +453,7 @@ private function getQuoteItemData()
450453
$quoteItem->getProduct(),
451454
'product_thumbnail_image'
452455
)->getUrl();
456+
$quoteItemData[$index]['message'] = $quoteItem->getMessage();
453457
}
454458
}
455459
return $quoteItemData;
@@ -776,4 +780,22 @@ private function getAttributeLabels(array $customAttribute, string $customAttrib
776780

777781
return $attributeOptionLabels;
778782
}
783+
784+
/**
785+
* Get notification messages for the quote items
786+
*
787+
* @param array $quoteItemData
788+
* @return array
789+
*/
790+
private function getQuoteItemsMessages(array $quoteItemData): array
791+
{
792+
$quoteItemsMessages = [];
793+
if ($quoteItemData) {
794+
foreach ($quoteItemData as $item) {
795+
$quoteItemsMessages[$item['item_id']] = $item['message'];
796+
}
797+
}
798+
799+
return $quoteItemsMessages;
800+
}
779801
}

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979

8080
<amOnPage stepKey="s96" url="{{AdminCustomerPage.url}}"/>
8181
<waitForPageLoad stepKey="s97"/>
82+
<waitForElementVisible selector="{{AdminCustomerFiltersSection.filtersButton}}" time="30" stepKey="waitFiltersButton"/>
8283
<click stepKey="s98" selector="{{AdminCustomerFiltersSection.filtersButton}}"/>
8384
<fillField stepKey="s99" selector="{{AdminCustomerFiltersSection.emailInput}}" userInput="$$simpleuscustomer.email$$"/>
8485
<click stepKey="s100" selector="{{AdminCustomerFiltersSection.apply}}"/>

app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@
404404
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/subtotal</item>
405405
<item name="displayArea" xsi:type="string">after_details</item>
406406
</item>
407+
<item name="message" xsi:type="array">
408+
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/message</item>
409+
<item name="displayArea" xsi:type="string">item_message</item>
410+
</item>
407411
</item>
408412
</item>
409413
</item>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define(['uiComponent'], function (Component) {
7+
'use strict';
8+
9+
var quoteMessages = window.checkoutConfig.quoteMessages;
10+
11+
return Component.extend({
12+
defaults: {
13+
template: 'Magento_Checkout/summary/item/details/message'
14+
},
15+
displayArea: 'item_message',
16+
quoteMessages: quoteMessages,
17+
18+
/**
19+
* @param {Object} item
20+
* @return {null}
21+
*/
22+
getMessage: function (item) {
23+
if (this.quoteMessages[item['item_id']]) {
24+
return this.quoteMessages[item['item_id']];
25+
}
26+
27+
return null;
28+
}
29+
});
30+
});

app/code/Magento/Checkout/view/frontend/web/template/summary/item/details.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@
4343
</div>
4444
<!-- /ko -->
4545
</div>
46+
<!-- ko foreach: getRegion('item_message') -->
47+
<!-- ko template: getTemplate() --><!-- /ko -->
48+
<!-- /ko -->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<div class="cart item message notice" if="getMessage($parents[1])">
8+
<div data-bind="text: getMessage($parents[1])"></div>
9+
</div>

app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice;
1313
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructureFactory;
1414
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructure;
15+
use Magento\Framework\App\Config\ScopeConfigInterface;
16+
use Magento\Store\Model\ScopeInterface;
17+
use Magento\Framework\App\ObjectManager;
18+
use Magento\CatalogInventory\Model\Stock;
19+
use Magento\CatalogInventory\Model\Configuration;
1520

1621
/**
1722
* Configurable Products Price Indexer Resource model
@@ -65,6 +70,11 @@ class Configurable implements DimensionalIndexerInterface
6570
*/
6671
private $basePriceModifier;
6772

73+
/**
74+
* @var ScopeConfigInterface
75+
*/
76+
private $scopeConfig;
77+
6878
/**
6979
* @param BaseFinalPrice $baseFinalPrice
7080
* @param IndexTableStructureFactory $indexTableStructureFactory
@@ -74,6 +84,7 @@ class Configurable implements DimensionalIndexerInterface
7484
* @param BasePriceModifier $basePriceModifier
7585
* @param bool $fullReindexAction
7686
* @param string $connectionName
87+
* @param ScopeConfigInterface $scopeConfig
7788
*/
7889
public function __construct(
7990
BaseFinalPrice $baseFinalPrice,
@@ -83,7 +94,8 @@ public function __construct(
8394
\Magento\Framework\App\ResourceConnection $resource,
8495
BasePriceModifier $basePriceModifier,
8596
$fullReindexAction = false,
86-
$connectionName = 'indexer'
97+
$connectionName = 'indexer',
98+
ScopeConfigInterface $scopeConfig = null
8799
) {
88100
$this->baseFinalPrice = $baseFinalPrice;
89101
$this->indexTableStructureFactory = $indexTableStructureFactory;
@@ -93,10 +105,11 @@ public function __construct(
93105
$this->resource = $resource;
94106
$this->fullReindexAction = $fullReindexAction;
95107
$this->basePriceModifier = $basePriceModifier;
108+
$this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class);
96109
}
97110

98111
/**
99-
* {@inheritdoc}
112+
* @inheritdoc
100113
*
101114
* @throws \Exception
102115
*/
@@ -184,7 +197,19 @@ private function fillTemporaryOptionsTable(string $temporaryOptionsTableName, ar
184197
['le' => $this->getTable('catalog_product_entity')],
185198
'le.' . $linkField . ' = l.parent_id',
186199
[]
187-
)->columns(
200+
);
201+
202+
// Does not make sense to extend query if out of stock products won't appear in tables for indexing
203+
if ($this->isConfigShowOutOfStock()) {
204+
$select->join(
205+
['si' => $this->getTable('cataloginventory_stock_item')],
206+
'si.product_id = l.product_id',
207+
[]
208+
);
209+
$select->where('si.is_in_stock = ?', Stock::STOCK_IN_STOCK);
210+
}
211+
212+
$select->columns(
188213
[
189214
'le.entity_id',
190215
'customer_group_id',
@@ -250,7 +275,7 @@ private function getMainTable($dimensions)
250275
/**
251276
* Get connection
252277
*
253-
* return \Magento\Framework\DB\Adapter\AdapterInterface
278+
* @return \Magento\Framework\DB\Adapter\AdapterInterface
254279
* @throws \DomainException
255280
*/
256281
private function getConnection(): \Magento\Framework\DB\Adapter\AdapterInterface
@@ -272,4 +297,17 @@ private function getTable($tableName)
272297
{
273298
return $this->resource->getTableName($tableName, $this->connectionName);
274299
}
300+
301+
/**
302+
* Is flag Show Out Of Stock setted
303+
*
304+
* @return bool
305+
*/
306+
private function isConfigShowOutOfStock(): bool
307+
{
308+
return $this->scopeConfig->isSetFlag(
309+
Configuration::XML_PATH_SHOW_OUT_OF_STOCK,
310+
ScopeInterface::SCOPE_STORE
311+
);
312+
}
275313
}

app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_order-summary.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@
137137
}
138138

139139
.product-item {
140+
.product-item-details {
141+
&:extend(.abs-add-clearfix all);
142+
}
143+
140144
.product-item-inner {
141145
display: table;
142146
margin: 0 0 @indent__s;
@@ -166,6 +170,10 @@
166170
}
167171
}
168172
}
173+
174+
.message {
175+
margin-top: 10px;
176+
}
169177
}
170178

171179
.actions-toolbar {

0 commit comments

Comments
 (0)