Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.10.x' into include-child-att…
Browse files Browse the repository at this point in the history
…ributes-toggle
  • Loading branch information
fredden committed Jan 27, 2023
2 parents 0535614 + dc35a14 commit 42e1afa
Show file tree
Hide file tree
Showing 137 changed files with 3,474 additions and 573 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/01-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
extensions: mbstring, intl, bcmath, gd
ini-values: post_max_size=256M, max_execution_time=180

- name: "Downgrade Composer"
run: composer self-update 2.1.14

- name: Validate composer.json and composer.lock
run: composer validate

Expand Down
33 changes: 29 additions & 4 deletions .github/workflows/20-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@ jobs:
magento-versions: '2.4.4'
magento-editions: 'enterprise'
experimental: false
- php-versions: '8.1'
magento-versions: '2.4.5'
magento-editions: 'community'
experimental: true
- php-versions: '8.1'
magento-versions: '2.4.5'
magento-editions: 'enterprise'
experimental: true
- php-versions: '8.1'
magento-versions: '2.4.5-p1'
magento-editions: 'community'
experimental: true
- php-versions: '8.1'
magento-versions: '2.4.5-p1'
magento-editions: 'enterprise'
experimental: true
- php-versions: '8.1'
magento-versions: '2.4.6-beta1'
magento-editions: 'community'
experimental: true
- php-versions: '8.1'
magento-versions: '2.4.6-beta1'
magento-editions: 'enterprise'
experimental: true

continue-on-error: ${{ matrix.experimental }}

Expand Down Expand Up @@ -108,6 +132,8 @@ jobs:
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $(version $MAGENTO_VERSION) -lt $(version "2.4.2") ]; then
composer self-update --1
else
composer self-update 2.1.14
fi
- name: "[Init] Optimize Composer"
Expand All @@ -133,7 +159,6 @@ jobs:
composer-${{ matrix.php-versions }}-${{ matrix.magento-editions }}-${{ matrix.magento-versions }}
composer-${{ matrix.php-versions }}-${{ matrix.magento-editions }}-
composer-${{ matrix.php-versions }}-
composer-
- name: "[Init] Cache Sample data repo"
id: sampledata-cache
Expand Down Expand Up @@ -196,7 +221,7 @@ jobs:
composer remove magento/module-configurable-sample-data-venia --no-update --no-interaction
composer remove magento/sample-data-media-venia --no-update --no-interaction
composer remove smile/elasticsuite --no-update --no-interaction
composer update --no-interaction --ignore-platform-reqs
composer update --no-interaction --ignore-platform-reqs magento/module-catalog-sample-data-venia magento/module-configurable-sample-data-venia magento/sample-data-media-venia smile/elasticsuite
composer config discard-changes false
- name: "[Init] Install proper version of Magento through Composer"
Expand Down Expand Up @@ -277,7 +302,7 @@ jobs:
composer require magento/module-catalog-sample-data-venia:dev-master@dev --no-update --no-interaction --ignore-platform-reqs
composer require magento/module-configurable-sample-data-venia:dev-master@dev --no-update --no-interaction --ignore-platform-reqs
composer require magento/sample-data-media-venia:dev-master@dev --no-update --no-interaction --ignore-platform-reqs
composer update --no-interaction --ignore-platform-reqs
composer update --no-interaction --ignore-platform-reqs magento/module-catalog-sample-data-venia magento/module-configurable-sample-data-venia magento/sample-data-media-venia
fi
- name: "[Test] Data : Require for Magento >=2.4.2"
Expand All @@ -291,7 +316,7 @@ jobs:
composer require magento/module-catalog-sample-data-venia --no-update --no-interaction --ignore-platform-reqs
composer require magento/module-configurable-sample-data-venia --no-update --no-interaction --ignore-platform-reqs
composer require magento/sample-data-media-venia --no-update --no-interaction --ignore-platform-reqs
composer update --no-interaction --ignore-platform-reqs
composer update --no-interaction --ignore-platform-reqs magento/module-catalog-sample-data-venia magento/module-configurable-sample-data-venia magento/sample-data-media-venia
fi
- name: "[Init] Data : Prepare for Magento >= 2.4.4"
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/99-no-response.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: No Response

on:
issue_comment:
types: [created]
schedule:
- cron: '30 * * * *'

jobs:
noResponse:
runs-on: ubuntu-latest
steps:
- uses: lee-dohm/[email protected]
with:
token: ${{ github.token }}
responseRequiredLabel: "needs update"
daysUntilClose: 14
closeComment: >-
This issue was waiting update from the author for too long.
Without any update, we are unfortunately not sure how to
resolve this issue.
We are therefore reluctantly going to close this
bug for now. Please don't hesitate to comment on the bug if you have
any more information for us; we will reopen it right away!
Thanks for your contribution.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
[![fork this repo](http://githubbadges.com/fork.svg?user=smile-sa&repo=elasticsuite&style=default)](https://github.com/smile-sa/elasticsuite/fork) ![GitHub contributors](https://img.shields.io/github/contributors/smile-sa/elasticsuite.svg?style=square) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=square)](https://github.com/Smile-SA/elasticsuite/pulls) ![Open Source Love](https://badges.frapsoft.com/os/v3/open-source.png?v=103)

<p align="center">
<a href="https://elasticsuite.io"><img alt="Smile" width="400px" src="doc/static/elasticsuite-logo.jpg" /></a>
<a href="https://elasticsuite.io/elastic-suite-pricing/"><img alt="Smile" src="doc/static/elasticsuite-banner-github.png" /></a>
</p>

## News

### 🎉 Hyvä compatibility

Elasticsuite is compatible with Hyvä theme. Please checkout [their blog article](https://hyva.io/blog/news/elasticsuite-hyva-partnership.html) to find out more about that.

If you want to use Elasticsuite with Hyvä theme, you'll need to install the [compatibility module](https://gitlab.hyva.io/hyva-themes/hyva-compat/magento2-smile-elasticsuite/)

### ⚠️ Magento versions compatibility :

Due to several changes in Magento 2.4.0, we cannot ensure compatibility between ElasticSuite <2.10 and Magento >=2.4.0 versions.
Expand All @@ -25,10 +31,11 @@ Magento **2.1.x** Opensource (CE) / Commerce (EE) |ElasticSuite **2.3.x** : ``
Magento **2.2.x** Opensource (CE) / Commerce (EE) |ElasticSuite **2.6.x** : ```composer require smile/elasticsuite ~2.6.0``` | 5.x & 6.x | No
Magento **<2.3.2** Opensource (CE) / Commerce (EE) |ElasticSuite **2.8.4** : ```composer require smile/elasticsuite 2.8.4``` | 5.x & 6.x | No
Magento **<2.3.5** Opensource (CE) / Commerce (EE) |ElasticSuite **2.8.x** : ```composer require smile/elasticsuite ~2.8.0``` | 5.x & 6.x | No
Magento **>=2.3.5** Opensource (CE) / Commerce (EE) |ElasticSuite **2.9.x** : ```composer require smile/elasticsuite ~2.9.0``` | 6.x & 7.x | **Yes**
Magento **>=2.3.5** Opensource (CE) / Commerce (EE) |ElasticSuite **2.9.x** : ```composer require smile/elasticsuite ~2.9.0``` | 6.x & 7.x | No
Magento **2.4.0** Opensource (CE) / Commerce (EE) |ElasticSuite **2.10.1** : ```composer require smile/elasticsuite 2.10.1``` | 6.x & 7.x | No
Magento **>=2.4.1** Opensource (CE) / Commerce (EE) |ElasticSuite **2.10.x** : ```composer require smile/elasticsuite ~2.10.0``` | 6.x & 7.x | **Yes**
Magento **>=2.4.4** Opensource (CE) / Commerce (EE) |ElasticSuite **>=2.10.10** : ```composer require smile/elasticsuite ~2.10.0``` | 6.x & 7.x | **Yes**
Magento **>=2.4.4** Opensource (CE) / Commerce (EE) |ElasticSuite **>=2.10.10** : ```composer require smile/elasticsuite ~2.10.10``` | 6.x & 7.x **and OpenSearch** | **Yes**
Magento **>=2.4.5** Opensource (CE) / Commerce (EE) |ElasticSuite **>=2.10.12** : ```composer require smile/elasticsuite ~2.10.12``` | 6.x & 7.x **and OpenSearch** | **Yes**

### Magento2 B2B Compatibility

Expand Down
Binary file added doc/static/elasticsuite-banner-github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ public function getJsConfig()
\Smile\ElasticsuiteTracker\Api\EventIndexInterface::INDEX_IDENTIFIER,
$this->reportContext->getStoreId()
);

if (!empty($dateBounds)) {
list($minDate, $maxDate) = $dateBounds;
$config['minDate'] = $this->formatDate($minDate, \IntlDateFormatter::SHORT, false, 'UTC');
$config['maxDate'] = $this->formatDate($maxDate, \IntlDateFormatter::SHORT, false, 'UTC');
$today = $this->_localeDate->date(null, null, true, false);
$config['minDate'] = - (int) $this->_localeDate->date($minDate, null, true, false)->diff($today)->days;
$config['maxDate'] = + (int) $this->_localeDate->date($maxDate, null, true, false)->diff($today)->days;
}

return $this->jsonSerializer->serialize($config);
Expand Down
19 changes: 14 additions & 5 deletions src/module-elasticsuite-analytics/Model/Report/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@ class Context
*/
private $request;

/**
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
*/
private $localeDate;

/**
* Context constructor.
*
* @param \Magento\Framework\App\RequestInterface $request App request.
* @param \Magento\Framework\App\RequestInterface $request App request.
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate Locale Date format.
*/
public function __construct(\Magento\Framework\App\RequestInterface $request)
{
$this->request = $request;
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
) {
$this->request = $request;
$this->localeDate = $localeDate;
}

/**
Expand Down Expand Up @@ -91,7 +100,7 @@ public function getDateRange()
private function createDateFromText($text)
{
try {
$date = new \DateTime($text);
$date = $this->localeDate->date($text, null, true, false);
} catch (\Exception $e) {
$date = new \DateTime(self::DEFAULT_TO_DATE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/module-elasticsuite-analytics/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<group id="search_terms" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Search terms configuration</label>
<field id="max_size" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="max_size" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Max search terms</label>
<validate>integer</validate>
<comment><![CDATA[Maximum number of search terms to display in the search usage report blocks.]]></comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ $hiddenTermsData = array_slice($termsData, $maxVisibleTerms);
], function($){
$(function() {

$("#<?= $block->getJsId() ?> .action-help").click(function(event) {
$("#<?= $block->getJsId() ?> .action-help").on('click', function(event) {
event.preventDefault();
$("#<?= $block->getJsId() ?> .dashboard-item-help").slideToggle();
});

$("#<?= $block->getJsId() ?>_toggle").click(function() {
$("#<?= $block->getJsId() ?>_toggle").on('click', function() {
if ($("#<?= $block->getJsId() ?>_extra").is(":hidden")) {
$(this).text('<?= $block->escapeJs(__('Show less...')) ?>');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ $hiddenTermsData = array_slice($termsData, $maxVisibleTerms);
'jquery'
], function($){
$(function() {
$("#<?= $block->getJsId() ?> .action-help").click(function(event) {
$("#<?= $block->getJsId() ?> .action-help").on('click', function(event) {
event.preventDefault();
$("#<?= $block->getJsId() ?> .dashboard-item-help").slideToggle();
});

$("#<?= $block->getJsId() ?>_toggle").click(function() {
$("#<?= $block->getJsId() ?>_toggle").on('click', function() {
if ($("#<?= $block->getJsId() ?>_extra").is(":hidden")) {
$(this).text('<?= $block->escapeJs(__('Show less...')) ?>');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function ($frontendLabel) use ($storeId) {
$result[$attributeCode]['options'] = $options;
$result[$attributeCode]['has_more'] = $hasMore;
$result[$attributeCode]['rel_nofollow'] = (bool) $attribute->getIsDisplayRelNofollow();
$result[$attributeCode]['frontend_input'] = $attribute->getFrontendInput();

if ($attributeCode !== 'attribute_set_id' &&
$attribute->getFacetSortOrder() == ElasticBucketInterface::SORT_ORDER_MANUAL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Smile\ElasticsuiteCatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder;

use Magento\Catalog\Model\Product\Attribute\Repository as AttributeRepository;
use Magento\CatalogGraphQl\DataProvider\Category\Query\CategoryAttributeQuery;
use Magento\CatalogGraphQl\DataProvider\CategoryAttributesMapper;
use Magento\CatalogGraphQl\DataProvider\Product\LayeredNavigation\Formatter\LayerFormatter;
Expand Down Expand Up @@ -72,25 +73,41 @@ class Category implements LayerBuilderInterface
*/
private $layerFormatter;

/**
* @var AttributeRepository
*/
private $attributeRepository;

/**
* @var string
*/
private $attributeCode;

/**
* @param CategoryAttributeQuery $categoryAttributeQuery Category Attribute Query
* @param CategoryAttributesMapper $categoryAttributesMapper Category Attributes Mapper
* @param RootCategoryProvider $rootCategoryProvider Root Category Provider
* @param LayerFormatter $layerFormatter Layer Formatter
* @param ResourceConnection $resourceConnection Resource Connection
* @param AttributeRepository $attributeRepository Product attribute repository
* @param string $attributeCode Product attribute code used to load the localized frontend label
*/
public function __construct(
CategoryAttributeQuery $categoryAttributeQuery,
CategoryAttributesMapper $categoryAttributesMapper,
RootCategoryProvider $rootCategoryProvider,
LayerFormatter $layerFormatter,
ResourceConnection $resourceConnection
ResourceConnection $resourceConnection,
AttributeRepository $attributeRepository,
string $attributeCode = 'category_ids'
) {
$this->categoryAttributeQuery = $categoryAttributeQuery;
$this->attributesMapper = $categoryAttributesMapper;
$this->rootCategoryProvider = $rootCategoryProvider;
$this->layerFormatter = $layerFormatter;
$this->resourceConnection = $resourceConnection;
$this->attributeRepository = $attributeRepository;
$this->attributeCode = $attributeCode;
}

/**
Expand Down Expand Up @@ -128,8 +145,12 @@ function (AggregationValueInterface $value) {
return [];
}

$label = __(self::$bucketMap[self::CATEGORY_BUCKET]['label']);
if ($frontendLabel = $this->getFrontendLabel($storeId)) {
$label = $frontendLabel;
}
$result = $this->layerFormatter->buildLayer(
self::$bucketMap[self::CATEGORY_BUCKET]['label'],
$label,
\count($categoryIds),
self::$bucketMap[self::CATEGORY_BUCKET]['request_name']
);
Expand All @@ -148,6 +169,9 @@ function (AggregationValueInterface $value) {

$result['has_more'] = false;

$attribute = $this->attributeRepository->get($this->attributeCode);
$result['frontend_input'] = $attribute->getFrontendInput();

return ['category_id' => $result];
}

Expand All @@ -162,4 +186,34 @@ private function isBucketEmpty(?BucketInterface $bucket): bool
{
return null === $bucket || !$bucket->getValues();
}

/**
* Return the frontend label of the configured attribute for the given store, if available.
*
* @param int|null $storeId Store ID.
*
* @return string|null
*/
private function getFrontendLabel(?int $storeId): ?string
{
$label = null;

try {
$attribute = $this->attributeRepository->get($this->attributeCode);
$label = $attribute->getDefaultFrontendLabel();
$frontendLabels = array_filter(
$attribute->getFrontendLabels(),
function ($frontendLabel) use ($storeId) {
return $frontendLabel->getStoreId() == $storeId;
}
);
if (!empty($frontendLabels)) {
$label = reset($frontendLabels)->getLabel();
}
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
;
}

return $label;
}
}
Loading

0 comments on commit 42e1afa

Please sign in to comment.