Skip to content

Commit 607729e

Browse files
author
Valeriy Nayda
committed
Merge remote-tracking branch 'origin/2.3-develop' into graphQl-44-product-textarea-field-format
2 parents 25fd467 + 6481cec commit 607729e

File tree

84 files changed

+1238
-449
lines changed

Some content is hidden

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

84 files changed

+1238
-449
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/Analytics/Test/Mftf/Test/AdminConfigurationIndustryTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<severity value="MAJOR"/>
1818
<testCaseId value="MAGETWO-63898"/>
1919
<group value="analytics"/>
20+
<skip>
21+
<issueId value="MAGETWO-96223"/>
22+
</skip>
2023
</annotations>
2124

2225
<actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/>

app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,7 @@ public function __construct(
122122
*/
123123
public function getAddToWishlistParams($product)
124124
{
125-
$continueUrl = $this->urlEncoder->encode($this->getUrl('customer/account'));
126-
$urlParamName = Action::PARAM_NAME_URL_ENCODED;
127-
128-
$continueUrlParams = [$urlParamName => $continueUrl];
129-
130-
return $this->_wishlistHelper->getAddParams($product, $continueUrlParams);
125+
return $this->_wishlistHelper->getAddParams($product);
131126
}
132127

133128
/**

app/code/Magento/Catalog/Model/Design.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Model;
77

8+
use \Magento\Framework\TranslateInterface;
9+
810
/**
911
* Catalog Custom Category design Model
1012
*
@@ -31,14 +33,20 @@ class Design extends \Magento\Framework\Model\AbstractModel
3133
*/
3234
protected $_localeDate;
3335

36+
/**
37+
* @var TranslateInterface
38+
*/
39+
private $translator;
40+
3441
/**
3542
* @param \Magento\Framework\Model\Context $context
3643
* @param \Magento\Framework\Registry $registry
3744
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
3845
* @param \Magento\Framework\View\DesignInterface $design
39-
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
40-
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
46+
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
47+
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
4148
* @param array $data
49+
* @param TranslateInterface|null $translator
4250
*/
4351
public function __construct(
4452
\Magento\Framework\Model\Context $context,
@@ -47,10 +55,13 @@ public function __construct(
4755
\Magento\Framework\View\DesignInterface $design,
4856
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
4957
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
50-
array $data = []
58+
array $data = [],
59+
TranslateInterface $translator = null
5160
) {
5261
$this->_localeDate = $localeDate;
5362
$this->_design = $design;
63+
$this->translator = $translator ?:
64+
\Magento\Framework\App\ObjectManager::getInstance()->get(TranslateInterface::class);
5465
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
5566
}
5667

@@ -63,6 +74,7 @@ public function __construct(
6374
public function applyCustomDesign($design)
6475
{
6576
$this->_design->setDesignTheme($design);
77+
$this->translator->loadData(null, true);
6678
return $this;
6779
}
6880

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
{

0 commit comments

Comments
 (0)