From 54ce0ad3f87280221ecb1949b26a784d44a2b237 Mon Sep 17 00:00:00 2001 From: David Molina Cano <128705267+davidmolinacano@users.noreply.github.com> Date: Wed, 11 Sep 2024 09:12:03 +0200 Subject: [PATCH] PLUGINRANGERS-2698 | [SUPPORT] Don't exclude non-searchable attributes (#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 --- Helper/StoreConfig.php | 3 +- composer.json | 2 +- etc/module.xml | 2 +- .../System/Config/customAttributes.phtml | 35 +++++++++++++++++-- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Helper/StoreConfig.php b/Helper/StoreConfig.php index 0170eb7..bd4886b 100644 --- a/Helper/StoreConfig.php +++ b/Helper/StoreConfig.php @@ -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(); @@ -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; } diff --git a/composer.json b/composer.json index fe8b734..dd7ce40 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/etc/module.xml b/etc/module.xml index 3d0bd4d..6a6f672 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/view/adminhtml/templates/System/Config/customAttributes.phtml b/view/adminhtml/templates/System/Config/customAttributes.phtml index 6307d83..d49700a 100755 --- a/view/adminhtml/templates/System/Config/customAttributes.phtml +++ b/view/adminhtml/templates/System/Config/customAttributes.phtml @@ -1,8 +1,15 @@ getHtmlId() ? $block->getHtmlId() : '_' . uniqid(); ?> +
-
+
@@ -11,7 +18,17 @@ - + + + + + + +
+ Select All/None +   + +
@@ -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.arrayAttributesescapeHtml($_htmlId) ?> = { // define row prototypeJS template