Skip to content

Commit bb01fce

Browse files
Merge remote-tracking branch 'remotes/github/2.3-develop' into EPAM-PR-61
2 parents 90fb9db + f17ca76 commit bb01fce

File tree

34 files changed

+6467
-162
lines changed

34 files changed

+6467
-162
lines changed

app/code/Magento/Checkout/view/frontend/web/js/region-updater.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ define([
157157
regionInput = $(this.options.regionInputId),
158158
postcode = $(this.options.postcodeId),
159159
label = regionList.parent().siblings('label'),
160-
requiredLabel = regionList.parents('div.field');
160+
container = regionList.parents('div.field');
161161

162162
this._clearError();
163163
this._checkRegionRequired(country);
@@ -181,15 +181,16 @@ define([
181181

182182
if (this.options.isRegionRequired) {
183183
regionList.addClass('required-entry').removeAttr('disabled');
184-
requiredLabel.addClass('required');
184+
container.addClass('required').show();
185185
} else {
186186
regionList.removeClass('required-entry validate-select').removeAttr('data-validate');
187-
requiredLabel.removeClass('required');
187+
container.removeClass('required');
188188

189189
if (!this.options.optionalRegionAllowed) { //eslint-disable-line max-depth
190-
regionList.attr('disabled', 'disabled');
190+
regionList.hide();
191+
container.hide();
191192
} else {
192-
regionList.removeAttr('disabled');
193+
regionList.show();
193194
}
194195
}
195196

@@ -201,12 +202,13 @@ define([
201202

202203
if (this.options.isRegionRequired) {
203204
regionInput.addClass('required-entry').removeAttr('disabled');
204-
requiredLabel.addClass('required');
205+
container.addClass('required').show();
205206
} else {
206207
if (!this.options.optionalRegionAllowed) { //eslint-disable-line max-depth
207208
regionInput.attr('disabled', 'disabled');
209+
container.hide();
208210
}
209-
requiredLabel.removeClass('required');
211+
container.removeClass('required');
210212
regionInput.removeClass('required-entry');
211213
}
212214

app/code/Magento/ConfigurableProductGraphQl/Model/Variant/Collection.php

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99

1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Model\Product;
12-
use Magento\Catalog\Model\ProductFactory;
1312
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection as ChildCollection;
1413
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\CollectionFactory;
1514
use Magento\Framework\EntityManager\MetadataPool;
1615
use Magento\Framework\Api\SearchCriteriaBuilder;
17-
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product as DataProvider;
16+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessorInterface;
1817

1918
/**
2019
* Collection for fetching configurable child product data.
@@ -26,21 +25,11 @@ class Collection
2625
*/
2726
private $childCollectionFactory;
2827

29-
/**
30-
* @var ProductFactory
31-
*/
32-
private $productFactory;
33-
3428
/**
3529
* @var SearchCriteriaBuilder
3630
*/
3731
private $searchCriteriaBuilder;
3832

39-
/**
40-
* @var DataProvider
41-
*/
42-
private $productDataProvider;
43-
4433
/**
4534
* @var MetadataPool
4635
*/
@@ -61,25 +50,27 @@ class Collection
6150
*/
6251
private $attributeCodes = [];
6352

53+
/**
54+
* @var CollectionProcessorInterface
55+
*/
56+
private $collectionProcessor;
57+
6458
/**
6559
* @param CollectionFactory $childCollectionFactory
66-
* @param ProductFactory $productFactory
6760
* @param SearchCriteriaBuilder $searchCriteriaBuilder
68-
* @param DataProvider $productDataProvider
6961
* @param MetadataPool $metadataPool
62+
* @param CollectionProcessorInterface $collectionProcessor
7063
*/
7164
public function __construct(
7265
CollectionFactory $childCollectionFactory,
73-
ProductFactory $productFactory,
7466
SearchCriteriaBuilder $searchCriteriaBuilder,
75-
DataProvider $productDataProvider,
76-
MetadataPool $metadataPool
67+
MetadataPool $metadataPool,
68+
CollectionProcessorInterface $collectionProcessor
7769
) {
7870
$this->childCollectionFactory = $childCollectionFactory;
79-
$this->productFactory = $productFactory;
8071
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
81-
$this->productDataProvider = $productDataProvider;
8272
$this->metadataPool = $metadataPool;
73+
$this->collectionProcessor = $collectionProcessor;
8374
}
8475

8576
/**
@@ -148,7 +139,11 @@ private function fetch() : array
148139
/** @var ChildCollection $childCollection */
149140
$childCollection = $this->childCollectionFactory->create();
150141
$childCollection->setProductFilter($product);
151-
$childCollection->addAttributeToSelect($attributeData);
142+
$this->collectionProcessor->process(
143+
$childCollection,
144+
$this->searchCriteriaBuilder->create(),
145+
$attributeData
146+
);
152147

153148
/** @var Product $childProduct */
154149
foreach ($childCollection->getItems() as $childProduct) {

app/code/Magento/Customer/etc/acl.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<resource id="Magento_Customer::config_customer" title="Customers Section" translate="title" sortOrder="50" />
2727
</resource>
2828
</resource>
29-
</resource>
29+
</resource>
3030
</resource>
3131
</resources>
3232
</acl>

app/code/Magento/DownloadableGraphQl/Model/Resolver/Product/DownloadableOptions.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Framework\GraphQl\Config\Element\Field;
2020
use Magento\Framework\GraphQl\Query\EnumLookup;
2121
use Magento\Framework\GraphQl\Query\ResolverInterface;
22+
use Magento\Framework\UrlInterface;
2223

2324
/**
2425
* @inheritdoc
@@ -47,22 +48,30 @@ class DownloadableOptions implements ResolverInterface
4748
*/
4849
private $linkCollection;
4950

51+
/**
52+
* @var UrlInterface
53+
*/
54+
private $urlBuilder;
55+
5056
/**
5157
* @param EnumLookup $enumLookup
5258
* @param DownloadableHelper $downloadableHelper
5359
* @param SampleCollection $sampleCollection
5460
* @param LinkCollection $linkCollection
61+
* @param UrlInterface|null $urlBuilder
5562
*/
5663
public function __construct(
5764
EnumLookup $enumLookup,
5865
DownloadableHelper $downloadableHelper,
5966
SampleCollection $sampleCollection,
60-
LinkCollection $linkCollection
67+
LinkCollection $linkCollection,
68+
UrlInterface $urlBuilder
6169
) {
6270
$this->enumLookup = $enumLookup;
6371
$this->downloadableHelper = $downloadableHelper;
6472
$this->sampleCollection = $sampleCollection;
6573
$this->linkCollection = $linkCollection;
74+
$this->urlBuilder = $urlBuilder;
6675
}
6776

6877
/**
@@ -144,7 +153,10 @@ private function formatLinks(LinkCollection $links) : array
144153
}
145154

146155
$resultData[$linkKey]['sample_file'] = $link->getSampleFile();
147-
$resultData[$linkKey]['sample_url'] = $link->getSampleUrl();
156+
$resultData[$linkKey]['sample_url'] = $this->urlBuilder->getUrl(
157+
'downloadable/download/linkSample',
158+
['link_id' => $link->getId()]
159+
);
148160
}
149161
return $resultData;
150162
}
@@ -155,7 +167,7 @@ private function formatLinks(LinkCollection $links) : array
155167
* @param Collection $samples
156168
* @return array
157169
*/
158-
private function formatSamples(Collection $samples) : array
170+
private function formatSamples(Collection $samples): array
159171
{
160172
$resultData = [];
161173
foreach ($samples as $sampleKey => $sample) {
@@ -166,7 +178,10 @@ private function formatSamples(Collection $samples) : array
166178
$resultData[$sampleKey]['sample_type']
167179
= $this->enumLookup->getEnumValueFromField('DownloadableFileTypeEnum', $sample->getSampleType());
168180
$resultData[$sampleKey]['sample_file'] = $sample->getSampleFile();
169-
$resultData[$sampleKey]['sample_url'] = $sample->getSampleUrl();
181+
$resultData[$sampleKey]['sample_url'] = $this->urlBuilder->getUrl(
182+
'downloadable/download/sample',
183+
['sample_id' => $sample->getId()]
184+
);
170185
}
171186
return $resultData;
172187
}

app/code/Magento/DownloadableGraphQl/etc/schema.graphqls

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,29 @@ type DownloadableProduct implements ProductInterface, CustomizableProductInterfa
2424
links_title: String @doc(description: "The heading above the list of downloadable products")
2525
}
2626

27-
enum DownloadableFileTypeEnum @doc(description: "This enumeration specifies whether a link or sample is a file or URL") {
27+
enum DownloadableFileTypeEnum @deprecated(reason: "`sample_url` serves to get the downloadable sample") {
2828
FILE
2929
URL
3030
}
3131

3232
type DownloadableProductLinks @doc(description: "DownloadableProductLinks defines characteristics of a downloadable product") {
33-
id: Int @doc(description: "The unique ID for the link to the downloadable product")
33+
id: Int @deprecated(reason: "This information shoud not be exposed on frontend")
3434
title: String @doc(description: "The display name of the link")
3535
sort_order: Int @doc(description: "A number indicating the sort order")
36-
is_shareable: Boolean @doc(description: "Indicates whether the link is shareable")
36+
is_shareable: Boolean @deprecated(reason: "This information shoud not be exposed on frontend")
3737
price: Float @doc(description: "The price of the downloadable product")
38-
number_of_downloads: Int @doc(description: "The maximum number of times the product can be downloaded. A value of 0 means unlimited.")
39-
link_type: DownloadableFileTypeEnum @doc(description: "Either FILE or URL")
40-
sample_type: DownloadableFileTypeEnum @doc(description: "Either FILE or URL")
41-
sample_file: String @doc(description: "The relative path to the downloadable sample")
42-
sample_url: String @doc(description: "The relative URL to the downloadable sample")
38+
number_of_downloads: Int @deprecated(reason: "This information shoud not be exposed on frontend")
39+
link_type: DownloadableFileTypeEnum @deprecated(reason: "`sample_url` serves to get the downloadable sample")
40+
sample_type: DownloadableFileTypeEnum @deprecated(reason: "`sample_url` serves to get the downloadable sample")
41+
sample_file: String @deprecated(reason: "`sample_url` serves to get the downloadable sample")
42+
sample_url: String @doc(description: "URL to the downloadable sample")
4343
}
4444

4545
type DownloadableProductSamples @doc(description: "DownloadableProductSamples defines characteristics of a downloadable product") {
46-
id: Int @doc(description: "The unique ID for the downloadable product sample")
46+
id: Int @deprecated(reason: "This information shoud not be exposed on frontend")
4747
title: String @doc(description: "The display name of the sample")
4848
sort_order: Int @doc(description: "A number indicating the sort order")
49-
sample_type: DownloadableFileTypeEnum @doc(description: "Either FILE or URL")
50-
sample_file: String @doc(description: "The relative path to the downloadable sample")
51-
sample_url: String @doc(description: "The relative URL to the downloadable sample")
49+
sample_type: DownloadableFileTypeEnum @deprecated(reason: "`sample_url` serves to get the downloadable sample")
50+
sample_file: String @deprecated(reason: "`sample_url` serves to get the downloadable sample")
51+
sample_url: String @doc(description: "URL to the downloadable sample")
5252
}

app/code/Magento/Reports/Block/Adminhtml/Grid.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ protected function _prepareCollection()
135135
$data = $this->parameters->toArray();
136136

137137
if (!isset($data['report_from'])) {
138-
// getting all reports from 2001 year
139-
$date = (new \DateTime())->setTimestamp(mktime(0, 0, 0, 1, 1, 2001));
138+
// Get records for the past month
139+
$date = new \DateTime('-1 month');
140140
$data['report_from'] = $this->_localeDate->formatDateTime(
141141
$date,
142142
\IntlDateFormatter::SHORT,
@@ -145,7 +145,6 @@ protected function _prepareCollection()
145145
}
146146

147147
if (!isset($data['report_to'])) {
148-
// getting all reports from 2001 year
149148
$date = new \DateTime();
150149
$data['report_to'] = $this->_localeDate->formatDateTime(
151150
$date,

app/code/Magento/SendFriendGraphQl/Model/Provider/GetVisibleProduct.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ public function execute(int $productId): ProductInterface
4949
$product = $this->productRepository->getById($productId);
5050

5151
if (!in_array(
52-
$product->getVisibility(),
53-
$this->visibility->getVisibleInCatalogIds()
52+
(int) $product->getVisibility(),
53+
$this->visibility->getVisibleInSiteIds(),
54+
true
5455
)) {
5556
throw new GraphQlNoSuchEntityException(
5657
__("The product that was requested doesn't exist. Verify the product and try again.")

app/design/frontend/Magento/luma/Magento_Sales/web/css/source/_module.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
}
9898

9999
&.options {
100-
padding: 0 0 15px;
100+
padding: 10px 10px 15px;
101101
}
102102
}
103103

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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\TestModuleFedex\Model;
9+
10+
use Magento\Framework\Exception\NotFoundException;
11+
use Magento\Framework\HTTP\AsyncClient\Request;
12+
use Magento\Framework\Module\Dir;
13+
use Magento\Framework\Filesystem\Io\File;
14+
use Magento\Framework\Stdlib\ArrayManager;
15+
16+
/**
17+
* Load mock response body for Fedex rate request
18+
*/
19+
class MockResponseBodyLoader
20+
{
21+
private const RESPONSE_FILE_PATTERN = '%s/_files/mock_response_%s_%s.json';
22+
private const PATH_COUNTRY = 'RequestedShipment/Recipient/Address/CountryCode';
23+
private const PATH_SERVICE_TYPE = 'RequestedShipment/ServiceType';
24+
25+
/**
26+
* @var Dir
27+
*/
28+
private $moduleDirectory;
29+
30+
/**
31+
* @var File
32+
*/
33+
private $fileIo;
34+
35+
/**
36+
* @var ArrayManager
37+
*/
38+
private $arrayManager;
39+
40+
/**
41+
* @param Dir $moduleDirectory
42+
* @param File $fileIo
43+
* @param ArrayManager
44+
*/
45+
public function __construct(
46+
Dir $moduleDirectory,
47+
File $fileIo,
48+
ArrayManager $arrayManager
49+
) {
50+
$this->moduleDirectory = $moduleDirectory;
51+
$this->fileIo = $fileIo;
52+
$this->arrayManager = $arrayManager;
53+
}
54+
55+
/**
56+
* Loads mock response xml for a given request
57+
*
58+
* @param array $request
59+
* @return string
60+
* @throws NotFoundException
61+
*/
62+
public function loadForRequest(array $request): string
63+
{
64+
$moduleDir = $this->moduleDirectory->getDir('Magento_TestModuleFedex');
65+
66+
$type = strtolower($this->arrayManager->get(static::PATH_SERVICE_TYPE, $request) ?? 'general');
67+
$country = strtolower($this->arrayManager->get(static::PATH_COUNTRY, $request) ?? '');
68+
69+
$responsePath = sprintf(static::RESPONSE_FILE_PATTERN, $moduleDir, $type, $country);
70+
71+
if (!$this->fileIo->fileExists($responsePath)) {
72+
throw new NotFoundException(
73+
__('"%1" is not a valid mock response type for country "%2".', $type, $country)
74+
);
75+
}
76+
77+
return $this->fileIo->read($responsePath);
78+
}
79+
}

0 commit comments

Comments
 (0)