Skip to content

Commit

Permalink
Merge pull request Smile-SA#78 from Elastic-Suite/feat-ESP-252-Layere…
Browse files Browse the repository at this point in the history
…d-navigation-add-stock-discount-attributes

 #ESP-252 Add is discounted and is in stock attributes on layered nav…
  • Loading branch information
romainruaud authored Oct 14, 2021
2 parents 69766d3 + 6bf9584 commit e83591a
Show file tree
Hide file tree
Showing 25 changed files with 516 additions and 14 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"smile/module-elasticsuite-explain": "self.version",
"smile/module-elasticsuite-facet-recommender": "self.version",
"smile/module-elasticsuite-instant-search": "self.version",
"smile/module-elasticsuite-layered-navigation": "self.version",
"smile/module-elasticsuite-merchandiser": "self.version",
"smile/module-elasticsuite-merchandising-gauge": "self.version",
"smile/module-elasticsuite-recommender": "self.version",
Expand All @@ -78,6 +79,7 @@
"src/module-elasticsuite-explain/registration.php",
"src/module-elasticsuite-facet-recommender/registration.php",
"src/module-elasticsuite-instant-search/registration.php",
"src/module-elasticsuite-layered-navigation/registration.php",
"src/module-elasticsuite-merchandiser/registration.php",
"src/module-elasticsuite-merchandising-gauge/registration.php",
"src/module-elasticsuite-recommender/registration.php",
Expand All @@ -99,6 +101,7 @@
"Smile\\ElasticsuiteExplain\\": "src/module-elasticsuite-explain",
"Smile\\ElasticsuiteFacetRecommender\\": "src/module-elasticsuite-facet-recommender",
"Smile\\ElasticsuiteInstantSearch\\": "src/module-elasticsuite-instant-search",
"Smile\\ElasticsuiteLayeredNavigation\\": "src/module-elasticsuite-layered-navigation",
"Smile\\ElasticsuiteMerchandiser\\": "src/module-elasticsuite-merchandiser",
"Smile\\ElasticsuiteMerchandisingGauge\\": "src/module-elasticsuite-merchandising-gauge",
"Smile\\ElasticsuiteRecommender\\": "src/module-elasticsuite-recommender",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @package Smile\ElasticsuiteAbCampaign
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license * @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/

namespace Smile\ElasticsuiteAbCampaign\Block\Tracker\Variables\Page;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @package Smile\ElasticsuiteAbCampaign
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/

namespace Smile\ElasticsuiteAbCampaign\Cron;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @package Smile\ElasticsuiteConfigurableProduct
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/

namespace Smile\ElasticsuiteConfigurableProduct\Model\Search\Configurable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* @package Smile\ElasticsuiteConfigurableProduct
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/
namespace Smile\ElasticsuiteConfigurableProduct\Plugin\Block\Product;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* @package Smile\ElasticsuiteConfigurableProduct
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/
namespace Smile\ElasticsuiteConfigurableProduct\Plugin\Block\Product;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* @package Smile\ElasticsuiteConfigurableProduct
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/
namespace Smile\ElasticsuiteConfigurableProduct\Plugin\Model\Resolver\Product;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* @package Smile\ElasticsuiteConfigurableProduct
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/
namespace Smile\ElasticsuiteConfigurableProduct\Plugin\Model\Resolver;

Expand Down
6 changes: 3 additions & 3 deletions src/module-elasticsuite-configurable-product/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The module version patterns are identical to those of Elasticsuite.

Magento Version | ElasticSuite Version | Module version | Module composer install | Supported Elasticsearch Version | Actively maintained
----------------------------------------------------|-------------------------|----------------|----------------------------------------------------------------------|---------------------------------|---------------------
Magento **<2.3.5** Opensource (CE) / Commerce (EE) | ElasticSuite **2.8.x** | **2.8.x** | ```composer require smile/module-elasticsuite-ab-campaign ~2.8.0``` | 5.x & 6.x | No
Magento **>=2.3.5** Opensource (CE) / Commerce (EE) | ElasticSuite **2.9.x** | **2.9.x** | ```composer require smile/module-elasticsuite-ab-campaign ~2.9.0``` | 6.x & 7.x | **Yes**
Magento **>=2.4.1** Opensource (CE) / Commerce (EE) | ElasticSuite **2.10.x** | **2.10.x** | ```composer require smile/module-elasticsuite-ab-campaign ~2.10.0``` | 6.x & 7.x | **Yes**
Magento **<2.3.5** Opensource (CE) / Commerce (EE) | ElasticSuite **2.8.x** | **2.8.x** | ```composer require smile/module-elasticsuite-configurable-product ~2.8.0``` | 5.x & 6.x | No
Magento **>=2.3.5** Opensource (CE) / Commerce (EE) | ElasticSuite **2.9.x** | **2.9.x** | ```composer require smile/module-elasticsuite-configurable-product ~2.9.0``` | 6.x & 7.x | **Yes**
Magento **>=2.4.1** Opensource (CE) / Commerce (EE) | ElasticSuite **2.10.x** | **2.10.x** | ```composer require smile/module-elasticsuite-configurable-product ~2.10.0``` | 6.x & 7.x | **Yes**

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* @package Smile\ElasticsuiteConfigurableProduct
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
* @package Smile\ElasticsuiteConfigurableProduct
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/
-->
<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
3 changes: 2 additions & 1 deletion src/module-elasticsuite-explain/Plugin/ReindexOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* @package Smile\ElasticsuiteExplain
* @author Pierre Gauthier <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/
namespace Smile\ElasticsuiteExplain\Plugin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* @package Smile\ElasticsuiteExplain
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/

var config = {
Expand Down
16 changes: 16 additions & 0 deletions src/module-elasticsuite-layered-navigation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Standard composer ignored paths
composer.phar
/vendor/

# Standard IDEs ignored paths
.metadata
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.project
.buildpath
.idea
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
* versions in the future.
*
* @category Smile
* @package Smile\ElasticsuiteLayeredNavigation
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/
namespace Smile\ElasticsuiteLayeredNavigation\Model\LayeredNavAttribute;

use Magento\Customer\Model\Session as CustomerSession;
use Smile\ElasticsuiteCatalog\Api\LayeredNavAttributeInterface;

/**
* IsDiscounted class.
*
* @category Smile
* @package Smile\ElasticsuiteLayeredNavigation
* @author Botis <[email protected]>
*/
class IsDiscounted implements LayeredNavAttributeInterface
{
/**
* @var string
*/
public const ATTRIBUTE_CODE = 'es_is_discounted';

/**
* @var CustomerSession
*/
protected $customerSession;

/**
* IsDiscount constructor.
*
* @param CustomerSession $customerSession Customer session.
*/
public function __construct(
CustomerSession $customerSession
) {
$this->customerSession = $customerSession;
}

/**
* {@inheritdoc}
*/
public function getAttributeCode(): string
{
return self::ATTRIBUTE_CODE;
}

/**
* {@inheritdoc}
*/
public function getFilterField(): string
{
return 'price.is_discount';
}

/**
* {@inheritdoc}
*/
public function getAdditionalAggregationData(): array
{
$customerGroupId = $this->customerSession->getCustomerGroupId();

return [
'nestedFilter' => ['price.customer_group_id' => $customerGroupId], 'minDocCount' => 1,
];
}

/**
* {@inheritdoc}
*/
public function skipAttribute(): bool
{
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
* versions in the future.
*
* @category Smile
* @package Smile\ElasticsuiteLayeredNavigation
* @author Botis <[email protected]>
* @copyright 2021 Smile
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided.
* Unauthorized copying of this file, via any medium, is strictly prohibited.
*/
namespace Smile\ElasticsuiteLayeredNavigation\Model\LayeredNavAttribute;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Smile\ElasticsuiteCatalog\Api\LayeredNavAttributeInterface;
use Magento\CatalogInventory\Model\Configuration as CatalogInventoryConfiguration;

/**
* IsInStock class.
*
* @category Smile
* @package Smile\ElasticsuiteLayeredNavigation
* @author Botis <[email protected]>
*/
class IsInStock implements LayeredNavAttributeInterface
{
/**
* @var string
*/
public const ATTRIBUTE_CODE = 'es_is_in_stock';

/**
* @var ScopeConfigInterface
*/
protected $scopeConfig;

/**
* IsInStock constructor.
*
* @param ScopeConfigInterface $scopeConfig Scope config.
*/
public function __construct(
ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}

/**
* {@inheritdoc}
*/
public function getAttributeCode(): string
{
return self::ATTRIBUTE_CODE;
}

/**
* {@inheritdoc}
*/
public function getFilterField(): string
{
return 'stock.is_in_stock';
}

/**
* {@inheritdoc}
*/
public function getAdditionalAggregationData(): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function skipAttribute(): bool
{
return !(bool) $this->scopeConfig->getValue(CatalogInventoryConfiguration::XML_PATH_SHOW_OUT_OF_STOCK);
}
}
15 changes: 15 additions & 0 deletions src/module-elasticsuite-layered-navigation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## README

Readme for the whole Smile ElasticSuite is available [here](https://github.com/Smile-SA/elasticsuite).


**Which version should I use ?**

The module version patterns are identical to those of Elasticsuite.

Magento Version | ElasticSuite Version | Module version | Module composer install | Supported Elasticsearch Version | Actively maintained
----------------------------------------------------|-------------------------|----------------|----------------------------------------------------------------------|---------------------------------|---------------------
Magento **<2.3.5** Opensource (CE) / Commerce (EE) | ElasticSuite **2.8.x** | **2.8.x** | ```composer require smile/module-elasticsuite-layered-navigation ~2.8.0``` | 5.x & 6.x | No
Magento **>=2.3.5** Opensource (CE) / Commerce (EE) | ElasticSuite **2.9.x** | **2.9.x** | ```composer require smile/module-elasticsuite-layered-navigation ~2.9.0``` | 6.x & 7.x | **Yes**
Magento **>=2.4.1** Opensource (CE) / Commerce (EE) | ElasticSuite **2.10.x** | **2.10.x** | ```composer require smile/module-elasticsuite-layered-navigation ~2.10.0``` | 6.x & 7.x | **Yes**

Loading

0 comments on commit e83591a

Please sign in to comment.