Skip to content

Commit

Permalink
PLUGINRANGERS-2698 | [SUPPORT] Don't exclude non-searchable attributes (
Browse files Browse the repository at this point in the history
#342)

* feat: Don't exclude non-searchable attributes

* feat: Sorted attributes alphabetically + scrollable table

* feat: Added toggler to select/unselect all the custom fields

* feat: Changed table max-height to 450px, requested by the Product team
  • Loading branch information
davidmolinacano committed Sep 11, 2024
1 parent 21df3e5 commit 54ce0ad
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Helper/StoreConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ public function getCustomAttributes(?int $id = null, ?string $scope = ScopeInter
$attributes = [];
foreach ($attributeCollection as $attributeTmp) {
$attribute = $this->eavConfig->getAttribute(Product::ENTITY, $attributeTmp->getAttributeId());
if (!$attribute->getIsSearchable() || !$attribute->getIsVisible()) {
if (!$attribute->getIsVisible()) {
continue;
}
$attribute_id = $attribute->getAttributeId();
Expand All @@ -901,6 +901,7 @@ public function getCustomAttributes(?int $id = null, ?string $scope = ScopeInter
$enabled = isset($saved[$attribute_id]['enabled']) && $saved[$attribute_id]['enabled'];
$attributes[$attribute_id]['enabled'] = $enabled;
}
array_multisort(array_column($attributes, 'label'), SORT_ASC, $attributes);
return $attributes;
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doofinder/doofinder-magento2",
"version": "0.14.6",
"version": "0.14.7",
"description": "Doofinder module for Magento 2",
"type": "magento2-module",
"require": {
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Doofinder_Feed" setup_version="0.14.6">
<module name="Doofinder_Feed" setup_version="0.14.7">
<sequence>
<module name="Magento_Integration" />
</sequence>
Expand Down
35 changes: 33 additions & 2 deletions view/adminhtml/templates/System/Config/customAttributes.phtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?php
$_htmlId = $block->getHtmlId() ? $block->getHtmlId() : '_' . uniqid();
?>
<style>
/* To make custom attributes table scrollable */
.admin__df-custom-attributes-wrapper {
max-height: 450px;
overflow-y: auto;
}
</style>
<div class="design_theme_ua_regexp" id="grid<?= $block->escapeHtml($_htmlId) ?>">
<div class="admin__control-table-wrapper">
<div class="admin__control-table-wrapper admin__df-custom-attributes-wrapper">
<table class="admin__control-table">
<thead>
<tr>
Expand All @@ -11,7 +18,17 @@
<?php endforeach ?>
</tr>
</thead>
<tbody id="addRow<?= $block->escapeHtml($_htmlId) ?>"></tbody>
<tbody id="addRow<?= $block->escapeHtml($_htmlId) ?>">
<tr>
<td>
<strong class="productsorting_code input-text">Select All/None</strong>
</td>
<td>&nbsp;</td>
<td>
<input type="checkbox" id="toggle-custom-fields" class="input-text">
</td>
</tr>
</tbody>
</table>
</div>
<input type="hidden" name="<?= $block->escapeHtml($block->getElement()->getName()) ?>[__empty]" value="" />
Expand All @@ -21,6 +38,20 @@
'mage/template',
'prototype'
], function (mageTemplate) {
function toggleCustomAttributesCheckboxes(event) {
const checkboxes = document.querySelectorAll('.admin__df-custom-attributes-wrapper input[type="checkbox"]:not(#toggle-custom-fields)');
const checkboxStatus = event.target.checked;
checkboxes.forEach(function(checkbox) {
checkbox.checked = checkboxStatus;
});
}

const customFieldsToggler = document.getElementById('toggle-custom-fields');
if (null !== customFieldsToggler) {
customFieldsToggler.checked = false;
customFieldsToggler.addEventListener('change', toggleCustomAttributesCheckboxes);
}

// create row creator
window.arrayAttributes<?= $block->escapeHtml($_htmlId) ?> = {
// define row prototypeJS template
Expand Down

0 comments on commit 54ce0ad

Please sign in to comment.