diff --git a/src/Service/GridData/DataObject.php b/src/Service/GridData/DataObject.php index ceca4bd4dc..2feebb4ea9 100644 --- a/src/Service/GridData/DataObject.php +++ b/src/Service/GridData/DataObject.php @@ -26,6 +26,7 @@ use Pimcore\Model\DataObject\Service; use Pimcore\Tool\Admin as AdminTool; use Pimcore\Tool\Session; +use Pimcore\Model\DataObject\ClassDefinition\Data; use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface; /** @@ -180,7 +181,7 @@ public static function getData(AbstractObject $object, array $fields = null, str } // because the key for the classification store has not a direct getter, you have to check separately if the data is inheritable - if (str_starts_with($key, '~') && empty($data[$key]['value'])) { + if (str_starts_with($key, '~') && self::getClassificationStoreFieldDefinition($key)->isEmpty(is_array($data[$key]) ? $data[$key]['value'] : $data[$key])) { $type = $keyParts[1]; if ($type === 'classificationstore') { @@ -349,7 +350,7 @@ protected static function getInheritedData(Concrete $object, string $key, string } $inheritedValue = self::getStoreValueForObject($parent, $key, $requestedLanguage); - if (!empty($inheritedValue['value'])) { + if (!self::getClassificationStoreFieldDefinition($key)->isEmpty(is_array($inheritedValue) ? $inheritedValue['value'] : $inheritedValue)) { return [ 'parent' => $parent, 'value' => $inheritedValue, @@ -358,4 +359,17 @@ protected static function getInheritedData(Concrete $object, string $key, string return self::getInheritedData($parent, $key, $requestedLanguage); } + + protected static function getClassificationStoreFieldDefinition(string $key): Data + { + $keyParts = explode('~', $key); + $groupKeyId = explode('-', $keyParts[3]); + + $keyid = (int) $groupKeyId[1]; + + $keyConfig = Model\DataObject\Classificationstore\KeyConfig::getById($keyid); + $type = $keyConfig->getType(); + $definition = json_decode($keyConfig->getDefinition(), true); + return \Pimcore\Model\DataObject\Classificationstore\Service::getFieldDefinitionFromJson($definition, $type); + } }