Skip to content

Add filterOnly facet modifier to the configuration #1128

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@
*/
class Algolia_Algoliasearch_Block_System_Config_Form_Field_Facets extends Algolia_Algoliasearch_Block_System_Config_Form_Field_AbstractField
{
const SEARCHABLE = '1';
const NOT_SEARCHABLE = '2';
const FILTER_ONLY = '3';

protected $_isQueryRulesDisabled;

public function __construct()
@@ -44,10 +48,11 @@ public function __construct()
'style' => 'width: 100px;',
),
'searchable' => array(
'label' => 'Searchable?',
'label' => 'Modifier',
'options' => array(
'1' => 'Yes',
'2' => 'No'
self::SEARCHABLE => 'Searchable',
self::NOT_SEARCHABLE => 'Not Searchable',
self::FILTER_ONLY => 'Filter Only',
),
'rowMethod' => 'getSearchable',
),
Original file line number Diff line number Diff line change
@@ -258,8 +258,12 @@ public function setSettings($storeId, $saveToTmpIndicesToo = false)
}
} else {
$attribute = $facet['attribute'];
if (array_key_exists('searchable', $facet) && $facet['searchable'] === '1') {
$attribute = 'searchable('.$attribute.')';
if (array_key_exists('searchable', $facet)) {
if ($facet['searchable'] === Algolia_Algoliasearch_Block_System_Config_Form_Field_Facets::SEARCHABLE) {
$attribute = 'searchable(' . $attribute . ')';
} elseif ($facet['searchable'] === Algolia_Algoliasearch_Block_System_Config_Form_Field_Facets::FILTER_ONLY) {
$attribute = 'filterOnly(' . $attribute . ')';
}
}

$attributesForFaceting[] = $attribute;
2 changes: 2 additions & 0 deletions app/code/community/Algolia/Algoliasearch/etc/system.xml
Original file line number Diff line number Diff line change
@@ -406,6 +406,8 @@
<br>
Set facet as searchable if you want your customers to be able to <a target="_blank" href="https://www.algolia.com/doc/api-reference/api-methods/search-for-facet-values/">search for facet values</a>. It's handy when a facet has a lot of values.
<br>
Set facet as Filter Only if only the <a target="_blank" href="https://www.algolia.com/doc/api-reference/api-parameters/attributesForFaceting/#parameter-option-filteronly">filtering feature</a> is needed.
<br>
Facets' documentation: <a target="_blank" href="https://community.algolia.com/magento/doc/m1/indexing/?utm_source=magento&utm_medium=extension&utm_campaign=magento_1&utm_term=shop-owner&utm_content=doc-link#facets">https://community.algolia.com/magento/doc/m1/indexing/#facets</a>
<br>
<br>