Skip to content

Commit 401d6ef

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents c5cc88b + 3cbe632 commit 401d6ef

File tree

122 files changed

+1854
-1442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1854
-1442
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\AsynchronousOperations\Model;
9+
10+
use Magento\AsynchronousOperations\Api\Data\OperationSearchResultsInterface;
11+
use Magento\Framework\Api\SearchResults;
12+
13+
/**
14+
* Service Data Object with bulk Operation search result.
15+
*/
16+
class OperationSearchResults extends SearchResults implements OperationSearchResultsInterface
17+
{
18+
}

app/code/Magento/AsynchronousOperations/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<preference for="Magento\AsynchronousOperations\Api\Data\SummaryOperationStatusInterface" type="Magento\AsynchronousOperations\Model\OperationStatus" />
1717
<preference for="Magento\AsynchronousOperations\Api\Data\DetailedBulkOperationsStatusInterface" type="Magento\AsynchronousOperations\Model\BulkStatus\Detailed" />
1818
<preference for="Magento\AsynchronousOperations\Api\Data\BulkOperationsStatusInterface" type="Magento\AsynchronousOperations\Model\BulkStatus\Short" />
19-
<preference for="Magento\AsynchronousOperations\Api\Data\OperationSearchResultsInterface" type="Magento\Framework\Api\SearchResults" />
19+
<preference for="Magento\AsynchronousOperations\Api\Data\OperationSearchResultsInterface" type="Magento\AsynchronousOperations\Model\OperationSearchResults" />
2020
<preference for="Magento\AsynchronousOperations\Api\OperationRepositoryInterface" type="Magento\AsynchronousOperations\Model\OperationRepository" />
2121
<type name="Magento\Framework\EntityManager\MetadataPool">
2222
<arguments>

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/StockDataFilter.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use Magento\CatalogInventory\Api\StockConfigurationInterface;
99
use Magento\Framework\App\Config\ScopeConfigInterface;
10-
use Magento\CatalogInventory\Model\Stock;
1110

1211
/**
1312
* Class StockDataFilter
@@ -61,8 +60,8 @@ public function filter(array $stockData)
6160
$stockData['qty'] = self::MAX_QTY_VALUE;
6261
}
6362

64-
if (isset($stockData['min_qty'])) {
65-
$stockData['min_qty'] = $this->purifyMinQty($stockData['min_qty'], $stockData['backorders']);
63+
if (isset($stockData['min_qty']) && (int)$stockData['min_qty'] < 0) {
64+
$stockData['min_qty'] = 0;
6665
}
6766

6867
if (!isset($stockData['is_decimal_divided']) || $stockData['is_qty_decimal'] == 0) {
@@ -71,27 +70,4 @@ public function filter(array $stockData)
7170

7271
return $stockData;
7372
}
74-
75-
/**
76-
* Purifies min_qty.
77-
*
78-
* @param int $minQty
79-
* @param int $backOrders
80-
* @return float
81-
*/
82-
private function purifyMinQty(int $minQty, int $backOrders): float
83-
{
84-
/**
85-
* As described in the documentation if the Backorders Option is disabled
86-
* it is recommended to set the Out Of Stock Threshold to a positive number.
87-
* That's why to clarify the logic to the end user the code below prevent him to set a negative number so such
88-
* a number will turn to zero.
89-
* @see https://docs.magento.com/m2/ce/user_guide/catalog/inventory-backorders.html
90-
*/
91-
if ($backOrders === Stock::BACKORDERS_NO && $minQty < 0) {
92-
$minQty = 0;
93-
}
94-
95-
return (float)$minQty;
96-
}
9773
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Model;
9+
10+
use Magento\Catalog\Api\Data\CategoryAttributeSearchResultsInterface;
11+
use Magento\Framework\Api\SearchResults;
12+
13+
/**
14+
* Service Data Object with Category Attribute search results.
15+
*/
16+
class CategoryAttributeSearchResults extends SearchResults implements CategoryAttributeSearchResultsInterface
17+
{
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Model;
9+
10+
use Magento\Catalog\Api\Data\CategorySearchResultsInterface;
11+
use Magento\Framework\Api\SearchResults;
12+
13+
/**
14+
* Service Data Object with Category search results.
15+
*/
16+
class CategorySearchResults extends SearchResults implements CategorySearchResultsInterface
17+
{
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Model;
9+
10+
use Magento\Catalog\Api\Data\ProductAttributeSearchResultsInterface;
11+
use Magento\Framework\Api\SearchResults;
12+
13+
/**
14+
* Service Data Object with Product Attribute search results.
15+
*/
16+
class ProductAttributeSearchResults extends SearchResults implements ProductAttributeSearchResultsInterface
17+
{
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Model;
9+
10+
use Magento\Catalog\Api\Data\ProductSearchResultsInterface;
11+
use Magento\Framework\Api\SearchResults;
12+
13+
/**
14+
* Service Data Object with Product search results.
15+
*/
16+
class ProductSearchResults extends SearchResults implements ProductSearchResultsInterface
17+
{
18+
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
99
use Magento\Catalog\Api\Data\ProductInterface;
1010
use Magento\Catalog\Api\Data\ProductAttributeInterface;
11+
use Magento\Framework\DB\Select;
12+
use Magento\Framework\DB\Sql\UnionExpression;
1113

1214
/**
1315
* Catalog Product Eav Select and Multiply Select Attributes Indexer resource model
@@ -199,13 +201,52 @@ protected function _prepareSelectIndex($entityIds = null, $attributeId = null)
199201
'dd.attribute_id',
200202
's.store_id',
201203
'value' => new \Zend_Db_Expr('COALESCE(ds.value, dd.value)'),
202-
'cpe.entity_id',
204+
'cpe.entity_id AS source_id',
203205
]
204206
);
205207

206208
if ($entityIds !== null) {
207209
$ids = implode(',', array_map('intval', $entityIds));
210+
$selectWithoutDefaultStore = $connection->select()->from(
211+
['wd' => $this->getTable('catalog_product_entity_int')],
212+
[
213+
'cpe.entity_id',
214+
'attribute_id',
215+
'store_id',
216+
'value',
217+
'cpe.entity_id',
218+
]
219+
)->joinLeft(
220+
['cpe' => $this->getTable('catalog_product_entity')],
221+
"cpe.{$productIdField} = wd.{$productIdField}",
222+
[]
223+
)->joinLeft(
224+
['d2d' => $this->getTable('catalog_product_entity_int')],
225+
sprintf(
226+
"d2d.store_id = 0 AND d2d.{$productIdField} = wd.{$productIdField} AND d2d.attribute_id = %s",
227+
$this->_eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'status')->getId()
228+
),
229+
[]
230+
)->joinLeft(
231+
['d2s' => $this->getTable('catalog_product_entity_int')],
232+
"d2s.store_id != 0 AND d2s.attribute_id = d2d.attribute_id AND " .
233+
"d2s.{$productIdField} = d2d.{$productIdField}",
234+
[]
235+
)
236+
->where((new \Zend_Db_Expr('COALESCE(d2s.value, d2d.value)')) . ' = ' . ProductStatus::STATUS_ENABLED)
237+
->where("wd.attribute_id IN({$attrIdsFlat})")
238+
->where('wd.value IS NOT NULL')
239+
->where('wd.store_id != 0')
240+
->where("cpe.entity_id IN({$ids})");
208241
$select->where("cpe.entity_id IN({$ids})");
242+
$selects = new UnionExpression(
243+
[$select, $selectWithoutDefaultStore],
244+
Select::SQL_UNION,
245+
'( %s )'
246+
);
247+
248+
$select = $connection->select();
249+
$select->from(['u' => $selects]);
209250
}
210251

211252
/**
@@ -342,7 +383,7 @@ private function getMultiSelectAttributeWithSourceModels($attrIds)
342383
ProductAttributeInterface::ENTITY_TYPE_CODE,
343384
$criteria
344385
)->getItems();
345-
386+
346387
$options = [];
347388
foreach ($attributes as $attribute) {
348389
$sourceModelOptions = $attribute->getOptions();
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
*
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
8+
namespace Magento\Catalog\Observer;
9+
10+
use Magento\Catalog\Model\Category;
11+
use Magento\Framework\Event\Observer as Event;
12+
use Magento\Framework\Event\ObserverInterface;
13+
use Magento\PageCache\Model\Cache\Type as PageCache;
14+
use Magento\PageCache\Model\Config as CacheConfig;
15+
16+
/**
17+
* Flush the built in page cache when a category is moved
18+
*/
19+
class FlushCategoryPagesCache implements ObserverInterface
20+
{
21+
22+
/**
23+
* @var CacheConfig
24+
*/
25+
private $cacheConfig;
26+
27+
/**
28+
*
29+
* @var PageCache
30+
*/
31+
private $pageCache;
32+
33+
/**
34+
* FlushCategoryPagesCache constructor.
35+
*
36+
* @param CacheConfig $cacheConfig
37+
* @param PageCache $pageCache
38+
*/
39+
public function __construct(CacheConfig $cacheConfig, PageCache $pageCache)
40+
{
41+
$this->cacheConfig = $cacheConfig;
42+
$this->pageCache = $pageCache;
43+
}
44+
45+
/**
46+
* Clean the category page cache if built in cache page cache is used.
47+
*
48+
* The built in cache requires cleaning all pages that contain the top category navigation menu when a
49+
* category is moved. This is because the built in cache does not support ESI blocks.
50+
*
51+
* @param Event $event
52+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
53+
*/
54+
public function execute(Event $event)
55+
{
56+
if ($this->cacheConfig->getType() == CacheConfig::BUILT_IN && $this->cacheConfig->isEnabled()) {
57+
$this->pageCache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, [Category::CACHE_TAG]);
58+
}
59+
}
60+
}

app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontOpenProductPageActionGroup.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,15 @@
1818
<amOnPage url="{{StorefrontProductPage.url(productUrl)}}" stepKey="openProductPage"/>
1919
<waitForPageLoad stepKey="waitForProductPageLoaded"/>
2020
</actionGroup>
21+
<actionGroup name="StorefrontOpenProductPageOnSecondStore">
22+
<annotations>
23+
<description>Goes to the Storefront Product page for the provided store code and Product URL.</description>
24+
</annotations>
25+
<arguments>
26+
<argument name="storeCode" type="string"/>
27+
<argument name="productUrl" type="string"/>
28+
</arguments>
29+
30+
<amOnPage url="{{StorefrontStoreViewProductPage.url(storeCode,productUrl)}}" stepKey="openProductPage"/>
31+
</actionGroup>
2132
</actionGroups>

0 commit comments

Comments
 (0)