pimcore / pimcore

Core Framework for the Open Source Data & Experience Management Platform (PIM, MDM, CDP, DAM, DXP/CMS & Digital Commerce)
http://www.pimcore.com
Other
3.38k stars 1.43k forks source link

Grid view cannot sort asc/desc on calculated values #4572

Closed NiklasBr closed 10 months ago

NiklasBr commented 5 years ago

Bug Report

Expected behavior

To be able to sort by calculated fields

Actual behavior

The grid view does not sort at all

Steps to reproduce

  1. Add a calculated value field (and the corresponding class and method) to an object
  2. Create at least two of those objects
  3. Open the grid view, configure it to show the calculated value's column
  4. Attempt to sort by that column, result: Sorting is not done at all.
weisswurstkanone commented 5 years ago

Did you save the objects first? Sorting is still based on the query table.

NiklasBr commented 5 years ago

All objects are saved, yes.

prugala commented 5 years ago

I tried to reproduce it. I used calcaulated value field with text and numbers only. In both cases sort works.

NiklasBr commented 5 years ago

Still cannot get it to work with this class in Pimcore 6 which should return the content of IfsName if displayName is empty. Both fields are regular input fields with "regular" human-readable product names like "Green sock size L".

class DisplayNameCalculator
{
    public static function compute($object, $context): ?string
    {
        if ($context->getFieldname() === 'displayNameCalculated') {
            /** @var \Pimcore\Model\DataObject\Product $object */
            $displayName = $object->getDisplayName();
            return $displayName ?? $object->getIfsName();
        }

        Logger::error("Tried to calculate unkown field displayNameCalculated for object id: {$object->getId()} of class {$object->getClassName()}");
        return null;
    }
}

Have cleared caches and re-saved objects countless times by now, sorting does not work.

prugala commented 5 years ago

I cant still reproduce problem.

I have 2 object with field name and names: Green Sock size L and Green Sock size S

After save I can sort with my calculated field.

My compute method:


public static function compute($object, $context): ?string
{
        /** @var \Pimcore\Model\DataObject\Test $object */
        return $object->getName();
}```
NiklasBr commented 5 years ago

Skärmbild (63)

Skärmbild (70)

Skärmbild (71)

Skärmbild (72)

Skärmbild (73)

Note how the last two are identical (and by all appearances randomly sorted the same way) even though I switched the ASC/DESC sort order. All other columns work fine for sorting both ascending and descending.

AlekMosingiewicz commented 5 years ago

@NiklasBr Basically, I've set everything up as you did, using the latest version of dev-master. Everything seems to work correctly. Maybe the problem is with UTF signs in the name?

class NameCalculator
{
    public static function compute($object, $context) {
        if ($context->getFieldname() === "realname") {
            $displayName = $object->getOthername();
            return $displayName ?? $object->getName();
        }

        Logger::error("Tried to calculate unkown field realname for object id: {$object->getId()} of class {$object->getClassName()}");
        return null;
    }
}

calcval calcval(1) calcval(2)

AlekMosingiewicz commented 5 years ago

Nope: calcval2 calcval3

stale[bot] commented 2 years ago

Thanks a lot for reporting the issue. The issue was not considered by us as "Priority" or "Backlog", so we're not gonna work on that anytime soon. In case this is a bug report, please create a pull request fixing the issue, we'll then review it as soon as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request, we'll then decide whether we'd accept it or not. Thanks for your understanding.

NiklasBr commented 2 years ago

This is still relevant

stale[bot] commented 2 years ago

Thanks a lot for reporting the issue. We did not consider the issue as "Priority" or "Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding.

NiklasBr commented 2 years ago

Just want to say that this still happens on 10.3

stale[bot] commented 2 years ago

Thanks a lot for reporting the issue. We did not consider the issue as "Priority" or "Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding.

NiklasBr commented 2 years ago

Yup, still happening on 10.3.5

fashxp commented 10 months ago

Dear community, it's been a while since that issue was updated the last time, so we decided to close it for now. If you're still interested in contributing, feel free to add comments here or contact us before creating a pull request to discuss next steps.

Thanks for your understanding.