Skip to content

Commit e6833c8

Browse files
committed
[FEATURE] [issue-3283] Added Filter Support for Yes/No
1 parent 80469a6 commit e6833c8

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ protected function _isOriginalIndexable()
478478
$backendType = $this->getOrigData('backend_type');
479479
$frontendInput = $this->getOrigData('frontend_input');
480480

481-
if ($backendType == 'int' && $frontendInput == 'select') {
481+
if ($backendType == 'int' && ($frontendInput == 'select' || $frontendInput == 'boolean')) {
482482
return true;
483483
} elseif ($backendType == 'varchar' && $frontendInput == 'multiselect') {
484484
return true;

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function _getIndexableAttributes($multiSelect)
8484
if ($multiSelect == true) {
8585
$select->where('ea.backend_type = ?', 'varchar')->where('ea.frontend_input = ?', 'multiselect');
8686
} else {
87-
$select->where('ea.backend_type = ?', 'int')->where('ea.frontend_input = ?', 'select');
87+
$select->where('ea.backend_type = ?', 'int')->where('ea.frontend_input IN( ? )', ['select', 'boolean']);
8888
}
8989

9090
return $this->getConnection()->fetchCol($select);

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function bindAttributeInputType()
5555
{
5656
checkOptionsPanelVisibility();
5757
switchDefaultValueField();
58-
if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){
58+
if($('frontend_input') && ($('frontend_input').value=='boolean' || $('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){
5959
if($('is_filterable') && !$('is_filterable').getAttribute('readonly')){
6060
$('is_filterable').disabled = false;
6161
}

app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
5454
[
5555
'name' => 'is_filterable',
5656
'label' => __("Use in Layered Navigation"),
57-
'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
58-
'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'),
57+
'title' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price'),
58+
'note' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price.'),
5959
'values' => [
6060
['value' => '0', 'label' => __('No')],
6161
['value' => '1', 'label' => __('Filterable (with results)')],
@@ -70,8 +70,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
7070
[
7171
'name' => 'is_filterable_in_search',
7272
'label' => __("Use in Search Results Layered Navigation"),
73-
'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
74-
'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'),
73+
'title' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price'),
74+
'note' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price.'),
7575
'values' => $this->optionList->toOptionArray(),
7676
]
7777
);

app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attribute_add_form.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<argument name="data" xsi:type="array">
1212
<item name="config" xsi:type="array">
1313
<item name="valuesForEnable" xsi:type="array">
14+
<item name="boolean" xsi:type="string">boolean</item>
1415
<item name="select" xsi:type="string">select</item>
1516
<item name="multiselect" xsi:type="string">multiselect</item>
1617
<item name="price" xsi:type="string">price</item>
@@ -19,7 +20,7 @@
1920
</item>
2021
</argument>
2122
<settings>
22-
<notice translate="true">Can be used only with catalog input type Dropdown, Multiple Select and Price.</notice>
23+
<notice translate="true">Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price.</notice>
2324
<dataType>string</dataType>
2425
<label translate="true">Use in Layered Navigation</label>
2526
<dataScope>is_filterable</dataScope>
@@ -36,6 +37,7 @@
3637
<argument name="data" xsi:type="array">
3738
<item name="config" xsi:type="array">
3839
<item name="valuesForEnable" xsi:type="array">
40+
<item name="boolean" xsi:type="string">boolean</item>
3941
<item name="select" xsi:type="string">select</item>
4042
<item name="multiselect" xsi:type="string">multiselect</item>
4143
<item name="price" xsi:type="string">price</item>
@@ -45,7 +47,7 @@
4547
</item>
4648
</argument>
4749
<settings>
48-
<notice translate="true">Can be used only with catalog input type Dropdown, Multiple Select and Price.</notice>
50+
<notice translate="true">Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price.</notice>
4951
<label translate="true">Use in Search Results Layered Navigation</label>
5052
<dataScope>is_filterable_in_search</dataScope>
5153
<imports>

app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ define([
4545
get tabsFront() {
4646
return this.attrTabsFront.length ? this.attrTabsFront.closest('li') : $('#front_fieldset-wrapper');
4747
},
48-
selectFields: ['select', 'multiselect', 'price', 'swatch_text', 'swatch_visual'],
48+
selectFields: ['boolean', 'select', 'multiselect', 'price', 'swatch_text', 'swatch_visual'],
4949

5050
/**
5151
* @this {swatchProductAttributes}

0 commit comments

Comments
 (0)