Skip to content

Commit 5a3eab5

Browse files
Merge branch '2.3-develop' of github.com:magento-epam/magento2ce into MAGETWO-91702
2 parents ffe154d + d7012b2 commit 5a3eab5

File tree

51 files changed

+814
-206
lines changed

Some content is hidden

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

51 files changed

+814
-206
lines changed

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ public function testGetAllWebsitesValue()
103103
$this->webSiteModel->expects($this->once())->method('getBaseCurrency')->willReturn($currency);
104104

105105
$expectedResult = AdvancedPricing::VALUE_ALL_WEBSITES . ' [' . $currencyCode . ']';
106-
$this->websiteString = $this->getMockBuilder(
106+
$websiteString = $this->getMockBuilder(
107107
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class
108108
)
109109
->setMethods(['_clearMessages', '_addMessages'])
110110
->setConstructorArgs([$this->storeResolver, $this->webSiteModel])
111111
->getMock();
112-
$result = $this->websiteString->getAllWebsitesValue();
112+
$result = $websiteString->getAllWebsitesValue();
113113

114114
$this->assertEquals($expectedResult, $result);
115115
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ Products,Products
233233
"This attribute set no longer exists.","This attribute set no longer exists."
234234
"You saved the attribute set.","You saved the attribute set."
235235
"Something went wrong while saving the attribute set.","Something went wrong while saving the attribute set."
236-
"You added product %1 to the comparison list.","You added product %1 to the comparison list."
237236
"You cleared the comparison list.","You cleared the comparison list."
238237
"Something went wrong clearing the comparison list.","Something went wrong clearing the comparison list."
239238
"You removed product %1 from the comparison list.","You removed product %1 from the comparison list."
@@ -808,4 +807,5 @@ Details,Details
808807
"Product Name or SKU", "Product Name or SKU"
809808
"Start typing to find products", "Start typing to find products"
810809
"Product with ID: (%1) doesn't exist", "Product with ID: (%1) doesn't exist"
811-
"Category with ID: (%1) doesn't exist", "Category with ID: (%1) doesn't exist"
810+
"Category with ID: (%1) doesn't exist", "Category with ID: (%1) doesn't exist"
811+
"You added product %1 to the <a href=""%2"">comparison list</a>.","You added product %1 to the <a href=""%2"">comparison list</a>."
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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\CatalogGraphQl\Model\Resolver\Product;
9+
10+
use Magento\Catalog\Model\Product;
11+
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\GraphQl\Config\Element\Field;
13+
use Magento\Framework\GraphQl\Query\ResolverInterface;
14+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15+
16+
/**
17+
* Returns product's image data
18+
*/
19+
class ProductImage implements ResolverInterface
20+
{
21+
/**
22+
* @inheritdoc
23+
*/
24+
public function resolve(
25+
Field $field,
26+
$context,
27+
ResolveInfo $info,
28+
array $value = null,
29+
array $args = null
30+
): array {
31+
if (!isset($value['model'])) {
32+
throw new LocalizedException(__('"model" value should be specified'));
33+
}
34+
35+
/** @var Product $product */
36+
$product = $value['model'];
37+
$imageType = $field->getName();
38+
39+
return [
40+
'model' => $product,
41+
'image_type' => $imageType,
42+
];
43+
}
44+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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\CatalogGraphQl\Model\Resolver\Product\ProductImage;
9+
10+
use Magento\Catalog\Model\Product;
11+
use Magento\Catalog\Model\ResourceModel\Product as ProductResourceModel;
12+
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\GraphQl\Config\Element\Field;
14+
use Magento\Framework\GraphQl\Query\ResolverInterface;
15+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
16+
use Magento\Store\Model\StoreManagerInterface;
17+
18+
/**
19+
* Returns product's image label
20+
*/
21+
class Label implements ResolverInterface
22+
{
23+
/**
24+
* @var ProductResourceModel
25+
*/
26+
private $productResource;
27+
28+
/**
29+
* @var StoreManagerInterface
30+
*/
31+
private $storeManager;
32+
33+
/**
34+
* @param ProductResourceModel $productResource
35+
* @param StoreManagerInterface $storeManager
36+
*/
37+
public function __construct(
38+
ProductResourceModel $productResource,
39+
StoreManagerInterface $storeManager
40+
) {
41+
$this->productResource = $productResource;
42+
$this->storeManager = $storeManager;
43+
}
44+
45+
/**
46+
* @inheritdoc
47+
*/
48+
public function resolve(
49+
Field $field,
50+
$context,
51+
ResolveInfo $info,
52+
array $value = null,
53+
array $args = null
54+
) {
55+
if (!isset($value['image_type'])) {
56+
throw new LocalizedException(__('"image_type" value should be specified'));
57+
}
58+
59+
if (!isset($value['model'])) {
60+
throw new LocalizedException(__('"model" value should be specified'));
61+
}
62+
63+
/** @var Product $product */
64+
$product = $value['model'];
65+
$imageType = $value['image_type'];
66+
$imagePath = $product->getData($imageType);
67+
$productId = (int)$product->getEntityId();
68+
69+
// null if image is not set
70+
if (null === $imagePath) {
71+
return $this->getAttributeValue($productId, 'name');
72+
}
73+
74+
$imageLabel = $this->getAttributeValue($productId, $imageType . '_label');
75+
if (null === $imageLabel) {
76+
$imageLabel = $this->getAttributeValue($productId, 'name');
77+
}
78+
79+
return $imageLabel;
80+
}
81+
82+
/**
83+
* Get attribute value
84+
*
85+
* @param int $productId
86+
* @param string $attributeCode
87+
* @return null|string Null if attribute value is not exists
88+
*/
89+
private function getAttributeValue(int $productId, string $attributeCode): ?string
90+
{
91+
$storeId = $this->storeManager->getStore()->getId();
92+
93+
$value = $this->productResource->getAttributeRawValue($productId, $attributeCode, $storeId);
94+
return is_array($value) && empty($value) ? null : $value;
95+
}
96+
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Image.php renamed to app/code/Magento/CatalogGraphQl/Model/Resolver/Product/ProductImage/Url.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\CatalogGraphQl\Model\Resolver\Product;
8+
namespace Magento\CatalogGraphQl\Model\Resolver\Product\ProductImage;
99

1010
use Magento\Catalog\Model\Product;
1111
use Magento\Catalog\Model\Product\ImageFactory;
@@ -15,13 +15,11 @@
1515
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1616

1717
/**
18-
* Returns product's image. If the image is not set, returns a placeholder
18+
* Returns product's image url
1919
*/
20-
class Image implements ResolverInterface
20+
class Url implements ResolverInterface
2121
{
2222
/**
23-
* Product image factory
24-
*
2523
* @var ImageFactory
2624
*/
2725
private $productImageFactory;
@@ -44,23 +42,36 @@ public function resolve(
4442
ResolveInfo $info,
4543
array $value = null,
4644
array $args = null
47-
): array {
45+
) {
46+
if (!isset($value['image_type'])) {
47+
throw new LocalizedException(__('"image_type" value should be specified'));
48+
}
49+
4850
if (!isset($value['model'])) {
4951
throw new LocalizedException(__('"model" value should be specified'));
5052
}
53+
5154
/** @var Product $product */
5255
$product = $value['model'];
53-
$imageType = $field->getName();
54-
$path = $product->getData($imageType);
56+
$imagePath = $product->getData($value['image_type']);
5557

58+
$imageUrl = $this->getImageUrl($value['image_type'], $imagePath);
59+
return $imageUrl;
60+
}
61+
62+
/**
63+
* Get image url
64+
*
65+
* @param string $imageType
66+
* @param string|null $imagePath Null if image is not set
67+
* @return string
68+
*/
69+
private function getImageUrl(string $imageType, ?string $imagePath): string
70+
{
5671
$image = $this->productImageFactory->create();
5772
$image->setDestinationSubdir($imageType)
58-
->setBaseFile($path);
73+
->setBaseFile($imagePath);
5974
$imageUrl = $image->getUrl();
60-
61-
return [
62-
'url' => $imageUrl,
63-
'path' => $path,
64-
];
75+
return $imageUrl;
6576
}
6677
}

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,13 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\
257257
meta_title: String @doc(description: "A string that is displayed in the title bar and tab of the browser and in search results lists")
258258
meta_keyword: String @doc(description: "A comma-separated list of keywords that are visible only to search engines")
259259
meta_description: String @doc(description: "A brief overview of the product for search results listings, maximum 255 characters")
260-
image: String @doc(description: "The relative path to the main image on the product page")
261-
small_image: ProductImage @doc(description: "The relative path to the small image, which is used on catalog pages") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Image")
262-
thumbnail: String @doc(description: "The relative path to the product's thumbnail image")
260+
image: ProductImage @doc(description: "The relative path to the main image on the product page") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage")
261+
small_image: ProductImage @doc(description: "The relative path to the small image, which is used on catalog pages") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage")
262+
thumbnail: ProductImage @doc(description: "The relative path to the product's thumbnail image") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage")
263263
new_from_date: String @doc(description: "The beginning date for new product listings, and determines if the product is featured as a new product") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\NewFromTo")
264264
new_to_date: String @doc(description: "The end date for new product listings") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\NewFromTo")
265265
tier_price: Float @doc(description: "The price when tier pricing is in effect and the items purchased threshold has been reached")
266266
options_container: String @doc(description: "If the product has multiple options, determines where they appear on the product page")
267-
image_label: String @doc(description: "The label assigned to a product image")
268-
small_image_label: String @doc(description: "The label assigned to a product's small image")
269-
thumbnail_label: String @doc(description: "The label assigned to a product's thumbnail image")
270267
created_at: String @doc(description: "Timestamp indicating when the product was created")
271268
updated_at: String @doc(description: "Timestamp indicating when the product was updated")
272269
country_of_manufacture: String @doc(description: "The product's country of origin")
@@ -352,9 +349,9 @@ type CustomizableFileValue @doc(description: "CustomizableFileValue defines the
352349
image_size_y: Int @doc(description: "The maximum height of an image")
353350
}
354351

355-
type ProductImage @doc(description: "Product image information. Contains image relative path and URL") {
356-
url: String
357-
path: String
352+
type ProductImage @doc(description: "Product image information. Contains image relative path, URL and label") {
353+
url: String @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage\\Url")
354+
label: String @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage\\Label")
358355
}
359356

360357
interface CustomizableOptionInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\CustomizableOptionTypeResolver") @doc(description: "The CustomizableOptionInterface contains basic information about a customizable option. It can be implemented by several types of configurable options.") {

app/code/Magento/CatalogImportExport/Model/Import/Uploader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Uploader extends \Magento\MediaStorage\Model\File\Uploader
101101
* @param \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension $validator
102102
* @param \Magento\Framework\Filesystem $filesystem
103103
* @param \Magento\Framework\Filesystem\File\ReadFactory $readFactory
104-
* @param null $filePath
104+
* @param null|string $filePath
105105
* @throws \Magento\Framework\Exception\LocalizedException
106106
*/
107107
public function __construct(
@@ -113,15 +113,15 @@ public function __construct(
113113
\Magento\Framework\Filesystem\File\ReadFactory $readFactory,
114114
$filePath = null
115115
) {
116-
if ($filePath !== null) {
117-
$this->_setUploadFile($filePath);
118-
}
119116
$this->_imageFactory = $imageFactory;
120117
$this->_coreFileStorageDb = $coreFileStorageDb;
121118
$this->_coreFileStorage = $coreFileStorage;
122119
$this->_validator = $validator;
123120
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
124121
$this->_readFactory = $readFactory;
122+
if ($filePath !== null) {
123+
$this->_setUploadFile($filePath);
124+
}
125125
}
126126

127127
/**
@@ -353,7 +353,7 @@ protected function _moveFile($tmpPath, $destPath)
353353
}
354354

355355
/**
356-
* {@inheritdoc}
356+
* @inheritdoc
357357
*/
358358
protected function chmod($file)
359359
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,4 @@ Payment,Payment
182182
"Items in Cart","Items in Cart"
183183
"Close","Close"
184184
"Show Cross-sell Items in the Shopping Cart","Show Cross-sell Items in the Shopping Cart"
185+
"You added %1 to your <a href=""%2"">shopping cart</a>.","You added %1 to your <a href=""%2"">shopping cart</a>."

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ define([
3535
var checkoutConfig = window.checkoutConfig,
3636
validators = [],
3737
observedElements = [],
38-
postcodeElement = null,
3938
postcodeElementName = 'postcode';
4039

4140
validators.push(defaultValidator);
@@ -79,7 +78,11 @@ define([
7978
}
8079

8180
$.each(elements, function (index, field) {
82-
uiRegistry.async(formPath + '.' + field)(self.doElementBinding.bind(self));
81+
var elementBinding = self.doElementBinding.bind(self),
82+
fullPath = formPath + '.' + field,
83+
func = uiRegistry.async(fullPath);
84+
85+
func(elementBinding);
8386
});
8487
},
8588

@@ -101,7 +104,6 @@ define([
101104

102105
if (element.index === postcodeElementName) {
103106
this.bindHandler(element, delay);
104-
postcodeElement = element;
105107
}
106108
},
107109

@@ -136,7 +138,7 @@ define([
136138
if (!formPopUpState.isVisible()) {
137139
clearTimeout(self.validateAddressTimeout);
138140
self.validateAddressTimeout = setTimeout(function () {
139-
self.postcodeValidation();
141+
self.postcodeValidation(element);
140142
self.validateFields();
141143
}, delay);
142144
}
@@ -148,7 +150,7 @@ define([
148150
/**
149151
* @return {*}
150152
*/
151-
postcodeValidation: function () {
153+
postcodeValidation: function (postcodeElement) {
152154
var countryId = $('select[name="country_id"]').val(),
153155
validationResult,
154156
warnMessage;
@@ -178,8 +180,8 @@ define([
178180
*/
179181
validateFields: function () {
180182
var addressFlat = addressConverter.formDataProviderToFlatData(
181-
this.collectObservedData(),
182-
'shippingAddress'
183+
this.collectObservedData(),
184+
'shippingAddress'
183185
),
184186
address;
185187

0 commit comments

Comments
 (0)