importX icon indicating copy to clipboard operation
importX copied to clipboard

class_key field is ignored

Open andrewcsp opened this issue 4 months ago • 1 comments

Using

  • ImportX 1.2.1-pl
  • MODX 3.1.2-pl

Observation I am importing several resources with ImportX, and I noted it always imports resources with the class_key to MODX\Revolution\modDocument regardless of the csv/data I insert into ImportX.

Suggestion / Fix The issue appears to be due to the setDefaultClassKey function. Line 104 (the if statement) is checking if $line['class_key'] is empty, it should however be checking $record['class_key']

    protected function setDefaultClassKey(array $record): array
    {
        $modxVersion = $this->modx->getVersionData();
        if (version_compare($modxVersion['full_version'], '3.0.0-dev', '>=') && empty($record['class_key'])) { // Note: using $record['class_key'] here
            $record['class_key'] = 'MODX\Revolution\modDocument';
        }

        return $record;
    }

andrewcsp avatar Sep 04 '25 12:09 andrewcsp

Hi @andrewcsp , thanks for letting us know! PRs are welcome if you're able to provide a fix, but otherwise we'll get it sorted next time it's worked on.

muzzwood avatar Sep 05 '25 01:09 muzzwood