Skip to content

Commit 2fc8179

Browse files
committed
Merge branch 'github-2.3-develop' into MAGETWO-98584
2 parents 83cb9a0 + 56e56ce commit 2fc8179

File tree

18 files changed

+286
-40
lines changed

18 files changed

+286
-40
lines changed

app/code/Magento/Catalog/Block/Product/View/Gallery.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ public function isMainImage($image)
207207
*/
208208
public function getImageAttribute($imageId, $attributeName, $default = null)
209209
{
210-
$attributes =
211-
$this->getConfigView()->getMediaAttributes('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE, $imageId);
210+
$attributes = $this->getConfigView()
211+
->getMediaAttributes('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE, $imageId);
212212
return $attributes[$attributeName] ?? $default;
213213
}
214214

app/code/Magento/Catalog/Helper/Image.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Helper;
77

88
use Magento\Framework\App\Helper\AbstractHelper;
9+
use Magento\Framework\View\Element\Block\ArgumentInterface;
910

1011
/**
1112
* Catalog image helper
@@ -14,7 +15,7 @@
1415
* @SuppressWarnings(PHPMD.TooManyFields)
1516
* @since 100.0.2
1617
*/
17-
class Image extends AbstractHelper
18+
class Image extends AbstractHelper implements ArgumentInterface
1819
{
1920
/**
2021
* Media config node
@@ -764,7 +765,7 @@ protected function getImageFile()
764765
protected function parseSize($string)
765766
{
766767
$size = explode('x', strtolower($string));
767-
if (sizeof($size) == 2) {
768+
if (count($size) == 2) {
768769
return ['width' => $size[0] > 0 ? $size[0] : null, 'height' => $size[1] > 0 ? $size[1] : null];
769770
}
770771
return false;

app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<block class="Magento\Catalog\Block\Product\View\Gallery" name="product.info.media.image" template="Magento_Catalog::product/view/gallery.phtml">
125125
<arguments>
126126
<argument name="gallery_options" xsi:type="object">Magento\Catalog\Block\Product\View\GalleryOptions</argument>
127+
<argument name="imageHelper" xsi:type="object">Magento\Catalog\Helper\Image</argument>
127128
</arguments>
128129
</block>
129130
<container name="skip_gallery_after.wrapper" htmlTag="div" htmlClass="action-skip-wrapper">

app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@
1212
* @var $block \Magento\Catalog\Block\Product\View\Gallery
1313
*/
1414
?>
15+
16+
<?php
17+
$images = $block->getGalleryImages()->getItems();
18+
$mainImage = current(array_filter($images, function ($img) use ($block) {
19+
return $block->isMainImage($img);
20+
}));
21+
22+
if (!empty($images) && empty($mainImage)) {
23+
$mainImage = $block->getGalleryImages()->getFirstItem();
24+
}
25+
26+
$helper = $block->getData('imageHelper');
27+
$mainImageData = $mainImage ?
28+
$mainImage->getData('medium_image_url') :
29+
$helper->getDefaultPlaceholderUrl('image');
30+
31+
?>
32+
1533
<div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
16-
<div data-role="loader" class="loading-mask">
17-
<div class="loader">
18-
<img src="<?= /* @escapeNotVerified */ $block->getViewFileUrl('images/loader-1.gif') ?>"
19-
alt="<?= /* @escapeNotVerified */ __('Loading...') ?>">
20-
</div>
21-
</div>
34+
<img
35+
alt="main product photo"
36+
class="gallery-placeholder__image"
37+
src="<?= /* @noEscape */ $mainImageData ?>"
38+
/>
2239
</div>
23-
<!--Fix for jumping content. Loader must be the same size as gallery.-->
24-
<script>
25-
var config = {
26-
"width": <?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_medium', 'width') ?>,
27-
"thumbheight": <?php /* @escapeNotVerified */ echo $block->getImageAttribute('product_page_image_small', 'height')
28-
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
29-
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navtype") ?>",
30-
"height": <?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_medium', 'height') ?>
31-
},
32-
thumbBarHeight = 0,
33-
loader = document.querySelectorAll('[data-gallery-role="gallery-placeholder"] [data-role="loader"]')[0];
34-
35-
if (config.navtype === 'horizontal') {
36-
thumbBarHeight = config.thumbheight;
37-
}
3840

39-
loader.style.paddingBottom = ( config.height / config.width * 100) + "%";
40-
</script>
4141
<script type="text/x-magento-init">
4242
{
4343
"[data-gallery-role=gallery-placeholder]": {
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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\Search\Adapter\Mysql\Query\Builder;
9+
10+
use Magento\Framework\DB\Helper\Mysql\Fulltext;
11+
use Magento\Framework\Search\Adapter\Mysql\Field\ResolverInterface;
12+
use Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match as BuilderMatch;
13+
use Magento\Framework\Search\Adapter\Preprocessor\PreprocessorInterface;
14+
use Magento\Framework\Search\Request\Query\BoolExpression;
15+
use Magento\Search\Helper\Data;
16+
17+
/**
18+
* @inheritdoc
19+
*/
20+
class Match extends BuilderMatch
21+
{
22+
/**
23+
* @var Data
24+
*/
25+
private $searchHelper;
26+
27+
/**
28+
* @param ResolverInterface $resolver
29+
* @param Fulltext $fulltextHelper
30+
* @param Data $searchHelper
31+
* @param string $fulltextSearchMode
32+
* @param PreprocessorInterface[] $preprocessors
33+
*/
34+
public function __construct(
35+
ResolverInterface $resolver,
36+
Fulltext $fulltextHelper,
37+
Data $searchHelper,
38+
$fulltextSearchMode = Fulltext::FULLTEXT_MODE_BOOLEAN,
39+
array $preprocessors = []
40+
) {
41+
parent::__construct($resolver, $fulltextHelper, $fulltextSearchMode, $preprocessors);
42+
$this->searchHelper = $searchHelper;
43+
}
44+
45+
/**
46+
* @inheritdoc
47+
*/
48+
protected function prepareQuery($queryValue, $conditionType)
49+
{
50+
$replaceSymbols = str_split(self::SPECIAL_CHARACTERS, 1);
51+
$queryValue = str_replace($replaceSymbols, ' ', $queryValue);
52+
foreach ($this->preprocessors as $preprocessor) {
53+
$queryValue = $preprocessor->process($queryValue);
54+
}
55+
56+
$stringPrefix = '';
57+
if ($conditionType === BoolExpression::QUERY_CONDITION_MUST) {
58+
$stringPrefix = '+';
59+
} elseif ($conditionType === BoolExpression::QUERY_CONDITION_NOT) {
60+
$stringPrefix = '-';
61+
}
62+
63+
$queryValues = explode(' ', $queryValue);
64+
65+
foreach ($queryValues as $queryKey => $queryValue) {
66+
if (empty($queryValue)) {
67+
unset($queryValues[$queryKey]);
68+
} else {
69+
$stringSuffix = $this->searchHelper->getMinQueryLength() > strlen($queryValue) ? '' : '*';
70+
$queryValues[$queryKey] = $stringPrefix . $queryValue . $stringSuffix;
71+
}
72+
}
73+
74+
$queryValue = implode(' ', $queryValues);
75+
76+
return $queryValue;
77+
}
78+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,6 @@
7878
</argument>
7979
</arguments>
8080
</virtualType>
81+
<preference for="Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match"
82+
type="Magento\CatalogGraphQl\Model\Search\Adapter\Mysql\Query\Builder\Match" />
8183
</config>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="SetMinimalQueryLengthActionGroup">
12+
<arguments>
13+
<argument name="minLength" type="string" defaultValue="1"/>
14+
</arguments>
15+
<amOnPage url="{{AdminCatalogSearchConfigurationPage.url}}" stepKey="navigateToConfigurationPage"/>
16+
<waitForPageLoad stepKey="wait1"/>
17+
<scrollTo selector="{{AdminCatalogSearchConfigurationSection.catalogSearchTab}}" stepKey="scrollToCatalogSearchTab"/>
18+
<conditionalClick selector="{{AdminCatalogSearchConfigurationSection.catalogSearchTab}}" dependentSelector="{{AdminCatalogSearchConfigurationSection.minQueryLength}}" visible="false" stepKey="expandCatalogSearchTab"/>
19+
<waitForElementVisible selector="{{AdminCatalogSearchConfigurationSection.minQueryLength}}" stepKey="waitTabToCollapse"/>
20+
<see userInput="{{MinMaxQueryLength.Hint}}" selector="{{AdminCatalogSearchConfigurationSection.minQueryLengthHint}}" stepKey="seeHint1"/>
21+
<see userInput="{{MinMaxQueryLength.Hint}}" selector="{{AdminCatalogSearchConfigurationSection.maxQueryLengthHint}}" stepKey="seeHint2"/>
22+
<uncheckOption selector="{{AdminCatalogSearchConfigurationSection.minQueryLengthInherit}}" stepKey="uncheckSystemValue"/>
23+
<fillField selector="{{AdminCatalogSearchConfigurationSection.minQueryLength}}" userInput="{{minLength}}" stepKey="setMinQueryLength"/>
24+
<click selector="{{AdminCatalogSearchConfigurationSection.catalogSearchTab}}" stepKey="collapseTab"/>
25+
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig"/>
26+
<waitForPageLoad stepKey="waitForConfigSaved"/>
27+
<see userInput="You saved the configuration." stepKey="seeSuccessMessage"/>
28+
</actionGroup>
29+
</actionGroups>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="SetMinQueryLengthToDefault" type="catalog_search_config_def">
12+
<requiredEntity type="enable">DefaultMinQueryLength</requiredEntity>
13+
</entity>
14+
<entity name="UncheckMinQueryLengthAndSet" type="catalog_search_config_query_length">
15+
<requiredEntity type="number">SetMinQueryLengthToOne</requiredEntity>
16+
</entity>
17+
<entity name="DefaultMinQueryLength" type="enable">
18+
<data key="inherit">true</data>
19+
</entity>
20+
<entity name="DefaultMinQueryLengthDisable" type="enable">
21+
<data key="inherit">0</data>
22+
</entity>
23+
<entity name="SetMinQueryLengthToOne" type="number">
24+
<data key="value">1</data>
25+
</entity>
26+
27+
</entities>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="MinMaxQueryLength" type="constant">
12+
<data key="Hint">This value must be compatible with the corresponding setting in the configured search engine</data>
13+
</entity>
14+
</entities>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
10+
<operation name="CatalogSearchConfigDefault" dataType="catalog_search_config_def" type="create" auth="adminFormKey" url="/admin/system_config/save/section/catalog/" method="POST">
11+
<object key="groups" dataType="catalog_search_config_def">
12+
<object key="search" dataType="catalog_search_config_def">
13+
<object key="fields" dataType="catalog_search_config_def">
14+
<object key="min_query_length" dataType="enable">
15+
<field key="inherit">boolean</field>
16+
</object>
17+
</object>
18+
</object>
19+
</object>
20+
</operation>
21+
<operation name="CatalogSearchConfigQueryLength" dataType="catalog_search_config_query_length" type="create" auth="adminFormKey" url="/admin/system_config/save/section/catalog/" method="POST">
22+
<object key="groups" dataType="catalog_search_config_query_length">
23+
<object key="search" dataType="catalog_search_config_query_length">
24+
<object key="fields" dataType="catalog_search_config_query_length">
25+
<object key="min_query_length" dataType="number">
26+
<field key="value">integer</field>
27+
</object>
28+
</object>
29+
</object>
30+
</object>
31+
</operation>
32+
</operations>

0 commit comments

Comments
 (0)