Skip to content

Commit 4c3a092

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents fb5dc9d + 06dbbc8 commit 4c3a092

File tree

4 files changed

+306
-1
lines changed

4 files changed

+306
-1
lines changed

app/code/Magento/Catalog/Ui/Component/UrlInput/Product.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
use Magento\Framework\UrlInterface;
1212

13+
/**
14+
* Returns configuration for product Url Input type
15+
*/
1316
class Product implements \Magento\Ui\Model\UrlInput\ConfigInterface
1417
{
1518
/**
@@ -27,7 +30,7 @@ public function __construct(UrlInterface $urlBuilder)
2730
}
2831

2932
/**
30-
* {@inheritdoc}
33+
* @inheritdoc
3134
*/
3235
public function getConfig(): array
3336
{
@@ -46,6 +49,7 @@ public function getConfig(): array
4649
'template' => 'ui/grid/filters/elements/ui-select',
4750
'searchUrl' => $this->urlBuilder->getUrl('catalog/product/search'),
4851
'filterPlaceholder' => __('Product Name or SKU'),
52+
'filterRateLimitMethod' => 'notifyWhenChangesStop',
4953
'isDisplayEmptyPlaceholder' => true,
5054
'emptyOptionsHtml' => __('Start typing to find products'),
5155
'missingValuePlaceholder' => __('Product with ID: %s doesn\'t exist'),
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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\Plugin;
9+
10+
use Magento\Catalog\Model\Product;
11+
use Magento\Framework\Message\MessageInterface;
12+
use Magento\Framework\View\DesignLoader as ViewDesignLoader;
13+
use Magento\Framework\Message\ManagerInterface;
14+
use Magento\Catalog\Block\Product\ImageFactory;
15+
16+
/**
17+
* Load necessary design files for GraphQL
18+
*/
19+
class DesignLoader
20+
{
21+
/**
22+
* @var DesignLoader
23+
*/
24+
private $designLoader;
25+
26+
/**
27+
* @var ManagerInterface
28+
*/
29+
private $messageManager;
30+
31+
/**
32+
* @param ViewDesignLoader $designLoader
33+
* @param ManagerInterface $messageManager
34+
*/
35+
public function __construct(
36+
ViewDesignLoader $designLoader,
37+
ManagerInterface $messageManager
38+
) {
39+
$this->designLoader = $designLoader;
40+
$this->messageManager = $messageManager;
41+
}
42+
43+
/**
44+
* Before create load the design files
45+
*
46+
* @param ImageFactory $subject
47+
* @param Product $product
48+
* @param string $imageId
49+
* @param array|null $attributes
50+
*
51+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
52+
*/
53+
public function beforeCreate(
54+
ImageFactory $subject,
55+
Product $product,
56+
string $imageId,
57+
array $attributes = null
58+
) {
59+
try {
60+
$this->designLoader->load();
61+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
62+
if ($e->getPrevious() instanceof \Magento\Framework\Config\Dom\ValidationException) {
63+
/** @var MessageInterface $message */
64+
$message = $this->messageManager
65+
->createMessage(MessageInterface::TYPE_ERROR)
66+
->setText($e->getMessage());
67+
$this->messageManager->addUniqueMessages([$message]);
68+
}
69+
}
70+
}
71+
}

app/code/Magento/CatalogGraphQl/etc/graphql/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,8 @@
137137
</argument>
138138
</arguments>
139139
</type>
140+
141+
<type name="Magento\Catalog\Block\Product\ImageFactory">
142+
<plugin name="designLoader" type="Magento\CatalogGraphQl\Plugin\DesignLoader" />
143+
</type>
140144
</config>

0 commit comments

Comments
 (0)