Skip to content

Commit 93b1d30

Browse files
committed
Merge branch 'feature-additional-country-regions' of github.com:nikolalardev/magento2 into feature-additional-country-regions
2 parents c172dc1 + 8e1d2d7 commit 93b1d30

File tree

70 files changed

+1922
-440
lines changed

Some content is hidden

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

70 files changed

+1922
-440
lines changed

app/code/Magento/Analytics/etc/config.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,12 @@
2323
<token/>
2424
</general>
2525
</analytics>
26+
<system>
27+
<media_storage_configuration>
28+
<allowed_resources>
29+
<analytics_folder>analytics</analytics_folder>
30+
</allowed_resources>
31+
</media_storage_configuration>
32+
</system>
2633
</default>
2734
</config>

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
304304
* Resolves relative path.
305305
*
306306
* @param string $path Absolute path
307+
* @param bool $fixPath
307308
* @return string Relative path
308309
*/
309310
private function normalizeRelativePath(string $path, bool $fixPath = false): string
@@ -358,7 +359,7 @@ public function isFile($path): bool
358359
return false;
359360
}
360361

361-
$path = $this->normalizeRelativePath($path, true);;
362+
$path = $this->normalizeRelativePath($path, true);
362363

363364
if ($this->adapter->has($path) && ($meta = $this->adapter->getMetadata($path))) {
364365
return ($meta['type'] ?? null) === self::TYPE_FILE;

app/code/Magento/AwsS3/Driver/AwsS3Factory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public function createConfigured(
8686
throw new DriverException(__('Bucket and region are required values'));
8787
}
8888

89+
if (!empty($config['http_handler'])) {
90+
$config['http_handler'] = $this->objectManager->create($config['http_handler'])($config);
91+
}
92+
8993
$client = new S3Client($config);
9094
$adapter = new AwsS3Adapter($client, $config['bucket'], $prefix);
9195

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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\AwsS3\Model;
9+
10+
use Aws\Handler\GuzzleV6\GuzzleHandler;
11+
use GuzzleHttp\Client;
12+
use GuzzleHttp\HandlerStack;
13+
use GuzzleHttp\MessageFormatter;
14+
use GuzzleHttp\Middleware;
15+
use Magento\Framework\App\Filesystem\DirectoryList;
16+
use Magento\Framework\Exception\FileSystemException;
17+
use Magento\Framework\Filesystem;
18+
use Monolog\Handler\StreamHandler;
19+
use Monolog\Logger;
20+
21+
final class HttpLoggerHandler
22+
{
23+
/**
24+
* @var Filesystem\Directory\WriteInterface
25+
*/
26+
private $directory;
27+
28+
/**
29+
* @var string
30+
*/
31+
private $file;
32+
33+
/**
34+
* @param Filesystem $filesystem
35+
* @param string $file
36+
* @throws FileSystemException
37+
*/
38+
public function __construct(
39+
Filesystem $filesystem,
40+
$file = 'debug/s3.log'
41+
) {
42+
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
43+
$this->file = $file;
44+
}
45+
46+
public function __invoke()
47+
{
48+
$this->directory->create(pathinfo($this->file, PATHINFO_DIRNAME));
49+
$localStream = $this->directory->getDriver()->fileOpen($this->directory->getAbsolutePath($this->file), 'a');
50+
$streamHandler = new StreamHandler($localStream, Logger::DEBUG, true, null, true);
51+
$logger = new \Monolog\Logger('S3', [$streamHandler]);
52+
$stack = HandlerStack::create();
53+
$stack->push(
54+
Middleware::log(
55+
$logger,
56+
new MessageFormatter('{code}:{method}:{target} {error}')
57+
)
58+
);
59+
return new GuzzleHandler(new Client(['handler' => $stack]));
60+
}
61+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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\Bundle\Model\Sales\Order\Shipment;
9+
10+
use Magento\Catalog\Model\Product\Type;
11+
use Magento\Sales\Model\ValidatorInterface;
12+
13+
/**
14+
* Validate if requested order items can be shipped according to bundle product shipment type
15+
*/
16+
class BundleShipmentTypeValidator implements ValidatorInterface
17+
{
18+
/**
19+
* @inheritdoc
20+
*/
21+
public function validate($item)
22+
{
23+
$result = [];
24+
if (!$item->isDummy(true)) {
25+
return $result;
26+
}
27+
28+
$message = 'Cannot create shipment as bundle product "%1" has shipment type "%2". ' .
29+
'%3 should be shipped instead.';
30+
31+
if ($item->getHasChildren() && $item->getProductType() === Type::TYPE_BUNDLE) {
32+
$result[] = __(
33+
$message,
34+
$item->getSku(),
35+
__('Separately'),
36+
__('Bundle product options'),
37+
);
38+
}
39+
40+
if ($item->getParentItem() && $item->getParentItem()->getProductType() === Type::TYPE_BUNDLE) {
41+
$result[] = __(
42+
$message,
43+
$item->getParentItem()->getSku(),
44+
__('Together'),
45+
__('Bundle product itself'),
46+
);
47+
}
48+
49+
return $result;
50+
}
51+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,11 @@
234234
</argument>
235235
</arguments>
236236
</type>
237+
<type name="Magento\Sales\Model\Order\Shipment\ShipmentItemsValidator">
238+
<arguments>
239+
<argument name="validators" xsi:type="array">
240+
<item name="shipment_type" xsi:type="object">Magento\Bundle\Model\Sales\Order\Shipment\BundleShipmentTypeValidator</item>
241+
</argument>
242+
</arguments>
243+
</type>
237244
</config>

app/code/Magento/Bundle/i18n/en_US.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@ Select...,Select...
105105
Status,Status
106106
Thumbnail,Thumbnail
107107
Type,Type
108+
"Cannot create shipment as bundle product ""%1"" has shipment type ""%2"". %3 should be shipped instead.","Cannot create shipment as bundle product ""%1"" has shipment type ""%2"". %3 should be shipped instead."
109+
"Bundle product itself","Bundle product itself"
110+
"Bundle product options","Bundle product options"

app/code/Magento/Catalog/Model/Product/Image.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
namespace Magento\Catalog\Model\Product;
77

88
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
9+
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
910
use Magento\Catalog\Model\View\Asset\ImageFactory;
1011
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
1112
use Magento\Framework\App\Filesystem\DirectoryList;
1213
use Magento\Framework\App\ObjectManager;
13-
use Magento\Framework\Exception\FileSystemException;
1414
use Magento\Framework\Image as MagentoImage;
1515
use Magento\Framework\Serialize\SerializerInterface;
16-
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
17-
use Magento\Framework\Filesystem\Driver\File as FilesystemDriver;
1816

1917
/**
2018
* Image operations
@@ -202,11 +200,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
202200
*/
203201
private $serializer;
204202

205-
/**
206-
* @var FilesystemDriver
207-
*/
208-
private $filesystemDriver;
209-
210203
/**
211204
* Constructor
212205
*
@@ -227,7 +220,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
227220
* @param array $data
228221
* @param SerializerInterface $serializer
229222
* @param ParamsBuilder $paramsBuilder
230-
* @param FilesystemDriver $filesystemDriver
231223
* @throws \Magento\Framework\Exception\FileSystemException
232224
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
233225
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
@@ -249,8 +241,7 @@ public function __construct(
249241
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
250242
array $data = [],
251243
SerializerInterface $serializer = null,
252-
ParamsBuilder $paramsBuilder = null,
253-
FilesystemDriver $filesystemDriver = null
244+
ParamsBuilder $paramsBuilder = null
254245
) {
255246
$this->_storeManager = $storeManager;
256247
$this->_catalogProductMediaConfig = $catalogProductMediaConfig;
@@ -265,7 +256,6 @@ public function __construct(
265256
$this->viewAssetPlaceholderFactory = $viewAssetPlaceholderFactory;
266257
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
267258
$this->paramsBuilder = $paramsBuilder ?: ObjectManager::getInstance()->get(ParamsBuilder::class);
268-
$this->filesystemDriver = $filesystemDriver ?: ObjectManager::getInstance()->get(FilesystemDriver::class);
269259
}
270260

271261
/**
@@ -675,12 +665,7 @@ public function getDestinationSubdir()
675665
public function isCached()
676666
{
677667
$path = $this->imageAsset->getPath();
678-
try {
679-
$isCached = is_array($this->loadImageInfoFromCache($path)) || $this->filesystemDriver->isExists($path);
680-
} catch (FileSystemException $e) {
681-
$isCached = false;
682-
}
683-
return $isCached;
668+
return is_array($this->loadImageInfoFromCache($path)) || $this->_mediaDirectory->isExist($path);
684669
}
685670

686671
/**
@@ -952,7 +937,7 @@ private function getImageSize($imagePath)
952937
*/
953938
private function saveImageInfoToCache(array $imageInfo, string $imagePath)
954939
{
955-
$imagePath = $this->cachePrefix . $imagePath;
940+
$imagePath = $this->cachePrefix . $imagePath;
956941
$this->_cacheManager->save(
957942
$this->serializer->serialize($imageInfo),
958943
$imagePath,
@@ -968,7 +953,7 @@ private function saveImageInfoToCache(array $imageInfo, string $imagePath)
968953
*/
969954
private function loadImageInfoFromCache(string $imagePath)
970955
{
971-
$imagePath = $this->cachePrefix . $imagePath;
956+
$imagePath = $this->cachePrefix . $imagePath;
972957
$cacheData = $this->_cacheManager->load($imagePath);
973958
if (!$cacheData) {
974959
return false;

app/code/Magento/Catalog/Test/Mftf/Test/CreateProductAttributeEntityTest/CreateProductAttributeEntityDateTest.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<severity value="BLOCKER"/>
1717
<testCaseId value="MC-10895"/>
1818
<group value="Catalog"/>
19-
<skip>
20-
<issueId value="MC-13817"/>
21-
</skip>
2219
<group value="mtf_migrated"/>
2320
</annotations>
2421

@@ -35,8 +32,9 @@
3532
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
3633
</after>
3734

38-
<!--Generate date for use as default value, needs to be MM/d/YYYY -->
35+
<!--Generate date for use as default value, needs to be MM/d/YYYY and mm/d/yy-->
3936
<generateDate date="now" format="m/j/Y" stepKey="generateDefaultDate"/>
37+
<generateDate date="now" format="m/j/y" stepKey="generateDateCompressedFormat"/>
4038

4139
<!--Navigate to Stores > Attributes > Product.-->
4240
<actionGroup ref="AdminOpenProductAttributePageActionGroup" stepKey="goToProductAttributes"/>
@@ -57,7 +55,7 @@
5755
<seeOptionIsSelected stepKey="assertInputType" selector="{{AttributePropertiesSection.InputType}}" userInput="{{dateProductAttribute.frontend_input}}"/>
5856
<seeOptionIsSelected stepKey="assertRequired" selector="{{AttributePropertiesSection.ValueRequired}}" userInput="{{dateProductAttribute.is_required_admin}}"/>
5957
<seeInField stepKey="assertAttrCode" selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" userInput="{{dateProductAttribute.attribute_code}}"/>
60-
<seeInField stepKey="assertDefaultValue" selector="{{AdvancedAttributePropertiesSection.DefaultValueDate}}" userInput="{$generateDefaultDate}"/>
58+
<seeInField stepKey="assertDefaultValue" selector="{{AdvancedAttributePropertiesSection.DefaultValueDate}}" userInput="{$generateDateCompressedFormat}"/>
6159

6260
<!--Go to New Product page, add Attribute and check values-->
6361
<amOnPage url="{{AdminProductCreatePage.url('4', 'simple')}}" stepKey="goToCreateSimpleProductPage"/>

app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ protected function setUp(): void
172172

173173
$this->productFactory = $this->getMockBuilder(
174174
\Magento\Catalog\Model\ResourceModel\ProductFactory::class
175-
)->addMethods(['getTypeId'])
175+
)->disableOriginalConstructor()
176+
->addMethods(['getTypeId'])
176177
->onlyMethods(['create'])
177178
->getMock();
178179

app/code/Magento/Checkout/Test/Unit/Model/ShippingInformationManagementTest.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Magento\Quote\Model\ShippingAssignmentFactory;
3333
use Magento\Quote\Model\ShippingFactory;
3434
use PHPUnit\Framework\MockObject\MockObject;
35+
use PHPUnit\Framework\MockObject\RuntimeException;
3536
use PHPUnit\Framework\TestCase;
3637

3738
/**
@@ -148,7 +149,7 @@ protected function setUp(): void
148149
'importCustomerAddressData',
149150
'save',
150151
'getShippingRateByCode',
151-
'getShippingMethod'
152+
'getShippingMethod',
152153
]
153154
)
154155
->disableOriginalConstructor()
@@ -167,7 +168,7 @@ protected function setUp(): void
167168
'collectTotals',
168169
'getExtensionAttributes',
169170
'setExtensionAttributes',
170-
'setBillingAddress'
171+
'setBillingAddress',
171172
]
172173
)
173174
->disableOriginalConstructor()
@@ -238,9 +239,7 @@ private function setShippingAssignmentsMocks($shippingMethod): void
238239
->willReturn(null);
239240
$this->shippingAddressMock->expects($this->once())
240241
->method('setLimitCarrier');
241-
$this->cartExtensionMock = $this->getMockBuilder(CartExtension::class)
242-
->addMethods(['getShippingAssignments', 'setShippingAssignments'])
243-
->getMock();
242+
$this->cartExtensionMock = $this->getCartExtensionMock();
244243
$this->cartExtensionFactoryMock->expects($this->once())
245244
->method('create')
246245
->willReturn($this->cartExtensionMock);
@@ -622,4 +621,21 @@ public function testSaveAddressInformation(): void
622621
$this->model->saveAddressInformation($cartId, $addressInformationMock)
623622
);
624623
}
624+
625+
/**
626+
* Build cart extension mock.
627+
*
628+
* @return MockObject
629+
*/
630+
private function getCartExtensionMock(): MockObject
631+
{
632+
$mockBuilder = $this->getMockBuilder(CartExtension::class);
633+
try {
634+
$mockBuilder->addMethods(['getShippingAssignments', 'setShippingAssignments']);
635+
} catch (RuntimeException $e) {
636+
// CartExtension already generated.
637+
}
638+
639+
return $mockBuilder->getMock();
640+
}
625641
}

0 commit comments

Comments
 (0)