Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Range filter is not working #2374

Open
xApep opened this issue Sep 21, 2022 · 6 comments
Open

Range filter is not working #2374

xApep opened this issue Sep 21, 2022 · 6 comments

Comments

@xApep
Copy link

xApep commented Sep 21, 2022

The more I do the more things are not working, or I just don't know how to set it up correctly =)

This is my module settings
image

This is initial dump before submitting the range filter form (item value of specs_dimension_depth: 70)
Untitled-2

If not adjusting the range filter, meaning min: 1 max: 110

  • no items are shown

No matter which value I set for max (above 99), eg. 100, 101

  • no items are shown

But if I set value for max under 100, for example 99

  • items are shown

This probably is not working as it should since no matter which max I would set that is above 70 (this is product specs_dimension_depth value), items should be shown.

image

Contao: 4.13.8
Isotope: 2.8.7

@xApep
Copy link
Author

xApep commented Sep 21, 2022

I have notice that if you use range filter for Price it works as it should.

The setting in Range filter module is for Depth which is "custom" Text field attribute.
image


I have locally one more isotope 2.7.x-dev where this is working.

@aschempp
Copy link
Member

it would be great if you could further debug this issue because I don't have that complex setup. Please create a pull request or patch if you have a solution to discuss 😊

@xApep
Copy link
Author

xApep commented Sep 27, 2022

Unfortunately my understanding of Isotope is not that comprehensive to debug that thing to the causing problem.

But what I have seen every range attribute (which we define as attribute number) works random (when it shows results), but the price field always works as it should.

What would be the fastest thing to do (on mine side) so that you can debug it? :)

@aschempp
Copy link
Member

What would be the fastest thing to do (on mine side) so that you can debug it? :)

we do offer paid support through the Isotope Circle (https://circle.isotopeecommerce.org) 🙃

@xApep
Copy link
Author

xApep commented Sep 28, 2022

You sir, needs to do better packaging to sell it :)

All thou I'm familiar how Isotope is developed, but still, we are talking about bugfix :)

...but I can make a few feature suggestion to push Isotope CRO to next level, of course for free :P

@criwas
Copy link

criwas commented Sep 26, 2024

Taking this up again with a solution. Had the same problem.

Contao 4.13.49
Isotope: 2.9.1

I found out, that even the digit-values are saved as varchar. I extended the TextField-Attribute to handle digits as numbers in the database. I have added a field to control the decimal places individually. Range filter works now. Not the cleanest, but it had to be done quickly :)

It makes some problems if you have an existing installation with non decimals values. I made some changes directly in the database, because I had no time to build a runonce-file.

config/config.php

\Isotope\Model\Attribute::registerModelType('text', 'App\Model\Attribute\TextField');

dca/tl_isotope_attribute.php

use Contao\CoreBundle\DataContainer\PaletteManipulator;
PaletteManipulator::create()
    ->addField('decimalPlaces', 'rgxp', PaletteManipulator::POSITION_BEFORE)
    ->applyToPalette('textdigit', 'tl_iso_attribute');

$GLOBALS['TL_DCA']['tl_iso_attribute']['fields']['decimalPlaces'] = [
    'exclude'                 => true,
    'inputType'               => 'text',
    'eval'                    => ['rgxp'=>'digit', 'tl_class'=>'w50'],
    'sql'                     => "int(5) unsigned NOT NULL default '0'"
];

languages/de/tl_isotope_attribute.php

$GLOBALS['TL_LANG']['tl_iso_attribute']['decimalPlaces'] = ['Nachkommastellen', 'Bitte geben Sie die Anzahl Nachkommastellen ein.'];

App/Model/Attribute/TextField.php

namespace App\Model\Attribute;

use Isotope\Model\Attribute\TextField as IsotopeTextField;

class TextField extends IsotopeTextField {
    /**
     * @inheritdoc
     */
    public function saveToDCA(array &$arrData) {
        parent::saveToDCA($arrData);
        
        $maxlength = (int) $this->maxlength ?: 255;

        if ('digit' === $this->rgxp) {
            if (0 < ($decimalPlaces = $this->decimalPlaces)) {
                $maxlength = $maxlength > 10 ? 10 : $maxlength;
                $default = str_pad('0.', ($decimalPlaces+2), '0', STR_PAD_RIGHT);
                $arrData['fields'][$this->field_name]['sql'] = "decimal($maxlength,$decimalPlaces) unsigned NOT NULL default '$default'";
            } else {
                $maxlength = $maxlength > 65 ? 65 : $maxlength;
                $arrData['fields'][$this->field_name]['sql'] = "int($maxlength) unsigned NOT NULL default '0'";
            }
        } else {
            $arrData['fields'][$this->field_name]['sql'] = "varchar($maxlength) NOT NULL default ''";
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants