Skip to content

Commit fcdb6bb

Browse files
authored
Merge pull request #3528 from magento-tsg-csl3/2.2-develop-pr13
[TSG-CSL3] For 2.2 (pr13)
2 parents be2badc + beaf8d2 commit fcdb6bb

File tree

12 files changed

+583
-82
lines changed

12 files changed

+583
-82
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,20 @@ public function getProductsPosition($category)
484484
$this->getCategoryProductTable(),
485485
['product_id', 'position']
486486
)->where(
487-
'category_id = :category_id'
487+
"{$this->getTable('catalog_category_product')}.category_id = ?",
488+
$category->getId()
488489
);
490+
$websiteId = $category->getStore()->getWebsiteId();
491+
if ($websiteId) {
492+
$select->join(
493+
['product_website' => $this->getTable('catalog_product_website')],
494+
"product_website.product_id = {$this->getTable('catalog_category_product')}.product_id",
495+
[]
496+
)->where(
497+
'product_website.website_id = ?',
498+
$websiteId
499+
);
500+
}
489501
$bind = ['category_id' => (int)$category->getId()];
490502

491503
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/ConfigurableImportExport/Model/Export/RowCustomizer.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\ConfigurableImportExport\Model\Export;
79

8-
use Magento\CatalogImportExport\Model\Export\RowCustomizerInterface;
910
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
10-
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableProductType;
11+
use Magento\CatalogImportExport\Model\Export\RowCustomizerInterface;
1112
use Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
13+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableProductType;
1214
use Magento\ImportExport\Model\Import;
15+
use Magento\Store\Model\Store;
16+
use Magento\Store\Model\StoreManagerInterface;
1317

18+
/**
19+
* Customizes output during export
20+
*/
1421
class RowCustomizer implements RowCustomizerInterface
1522
{
1623
/**
@@ -36,6 +43,19 @@ class RowCustomizer implements RowCustomizerInterface
3643
self::CONFIGURABLE_VARIATIONS_LABELS_COLUMN
3744
];
3845

46+
/**
47+
* @var StoreManagerInterface
48+
*/
49+
private $storeManager;
50+
51+
/**
52+
* @param StoreManagerInterface $storeManager
53+
*/
54+
public function __construct(StoreManagerInterface $storeManager)
55+
{
56+
$this->storeManager = $storeManager;
57+
}
58+
3959
/**
4060
* Prepare configurable data for export
4161
*
@@ -49,6 +69,9 @@ public function prepareData($collection, $productIds)
4969
$productCollection->addAttributeToFilter('entity_id', ['in' => $productIds])
5070
->addAttributeToFilter('type_id', ['eq' => ConfigurableProductType::TYPE_CODE]);
5171

72+
// set global scope during export
73+
$this->storeManager->setCurrentStore(Store::DEFAULT_STORE_ID);
74+
5275
while ($product = $productCollection->fetchItem()) {
5376
$productAttributesOptions = $product->getTypeInstance()->getConfigurableOptions($product);
5477
$this->configurableData[$product->getId()] = [];

app/code/Magento/ConfigurableImportExport/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"magento/module-eav": "101.0.*",
99
"magento/module-import-export": "100.2.*",
1010
"magento/module-configurable-product": "100.2.*",
11-
"magento/framework": "101.0.*"
11+
"magento/framework": "101.0.*",
12+
"magento/module-store": "100.2.*"
1213
},
1314
"type": "magento2-module",
1415
"version": "100.2.4",

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/code/Magento/Sales/Test/Mftf/Test/AdminAbleToShipPartiallyInvoicedItemsTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<scrollTo selector="{{AdminInvoiceItemsSection.itemQtyToInvoice('1')}}" stepKey="scrollToItemsInvoiced"/>
7070
<!--Change invoiced items count-->
7171
<fillField selector="{{AdminInvoiceItemsSection.itemQtyToInvoice('1')}}" userInput="5" stepKey="invoiceHalfTheItems"/>
72-
<waitForElementChange selector="{{AdminInvoiceItemsSection.updateQty}}" function="function($el) {return $el->isEnabled();}" stepKey="waitForUpdateQtyButtonEnabled"/>
72+
<waitForElementChange selector="{{AdminInvoiceItemsSection.updateQty}}" function="function($el) {return $el->isEnabled();}" stepKey="waitForEnabledQtyToBeInvoicedSubmitButton"/>
7373
<click selector="{{AdminInvoiceItemsSection.updateQty}}" stepKey="updateQtyToBeInvoiced"/>
7474
<waitForLoadingMaskToDisappear stepKey="waitForQtyToUpdate"/>
7575
<waitForElementVisible selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="waitforSubmitInvoiceBtn"/>
@@ -112,6 +112,7 @@
112112
<!--Submit refund-->
113113
<scrollTo selector="{{AdminCreditMemoItemsSection.itemQtyToRefund('1')}}" stepKey="scrollToItemsToRefund"/>
114114
<fillField selector="{{AdminCreditMemoItemsSection.itemQtyToRefund('1')}}" userInput="5" after="scrollToItemsToRefund" stepKey="fillQtyOfItemsToRefund"/>
115+
<waitForElementChange selector="{{AdminCreditMemoItemsSection.updateQty}}" function="function($el) {return $el->isEnabled();}" stepKey="waitForEnabledRefundQtySubmitButton"/>
115116
<click selector="{{AdminCreditMemoItemsSection.updateQty}}" stepKey="updateRefundQty"/>
116117
<waitForLoadingMaskToDisappear stepKey="waitForRefundQtyToUpdate"/>
117118
<waitForElementVisible selector="{{AdminCreditMemoTotalSection.submitRefundOffline}}" stepKey="seeSubmitRefundBtn"/>

0 commit comments

Comments
 (0)