From 2774cbef4f0cbd1f42319c7023626294f7dd4a63 Mon Sep 17 00:00:00 2001 From: Paul Verdu Date: Mon, 2 Oct 2023 15:24:52 +0200 Subject: [PATCH 1/3] Fix problem where persister is not saved or retrieved from config file --- src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php | 1 + .../Resources/config/serializer/Model.ImportDefinition.yml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php b/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php index 6755c430..15bdcfa9 100644 --- a/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php +++ b/src/DataDefinitionsBundle/Model/ImportDefinition/Dao.php @@ -152,6 +152,7 @@ public function save() 'forceLoadObject', 'loader', 'fetcher', + 'persister', ]; foreach ($dataRaw as $key => $value) { diff --git a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml index be7b7b33..f2426729 100755 --- a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml +++ b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml @@ -50,3 +50,7 @@ Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinition: expose: true type: boolean groups: [Detailed] + persister: + expose: true + type: string + groups: [Detailed] From a94d4c880165b4e701fd17bf5bfd5e28df3be461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanel=20P=C3=A4=C3=A4ro?= Date: Wed, 15 Nov 2023 10:58:32 +0200 Subject: [PATCH 2/3] allow 'o_id' system field to be mapped --- src/DataDefinitionsBundle/Service/FieldSelection.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DataDefinitionsBundle/Service/FieldSelection.php b/src/DataDefinitionsBundle/Service/FieldSelection.php index 8ba08ff6..f94e7718 100644 --- a/src/DataDefinitionsBundle/Service/FieldSelection.php +++ b/src/DataDefinitionsBundle/Service/FieldSelection.php @@ -27,6 +27,7 @@ public function getClassDefinition(DataObject\ClassDefinition $class): array $fields = $class->getFieldDefinitions(); $systemColumns = [ + 'o_id', 'o_published', 'o_key', 'o_parentId', From 74d46a844b7384dc21ea74f1849a8f67ca00cabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanel=20P=C3=A4=C3=A4ro?= Date: Wed, 7 Feb 2024 14:02:19 +0200 Subject: [PATCH 3/3] ability to enable/disable value inheritance when exporting --- .../Exporter/Exporter.php | 6 ++++++ .../Form/Type/ExportDefinitionType.php | 1 + .../Model/ExportDefinition.php | 21 +++++++++++++++++++ .../Model/ExportDefinition/Dao.php | 1 + .../Model/ExportDefinitionInterface.php | 10 +++++++++ .../serializer/Model.ExportDefinition.yml | 4 ++++ .../public/pimcore/js/export/item.js | 6 ++++++ .../Resources/translations/admin.en.yml | 1 + 8 files changed, 50 insertions(+) diff --git a/src/DataDefinitionsBundle/Exporter/Exporter.php b/src/DataDefinitionsBundle/Exporter/Exporter.php index 736fbc7a..c1f794db 100644 --- a/src/DataDefinitionsBundle/Exporter/Exporter.php +++ b/src/DataDefinitionsBundle/Exporter/Exporter.php @@ -21,6 +21,7 @@ use Exception; use InvalidArgumentException; use Pimcore; +use Pimcore\Model\DataObject; use Pimcore\Model\DataObject\Concrete; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -116,6 +117,9 @@ private function runExport( FetcherInterface $fetcher, ExportProviderInterface $provider ) { + $getInheritedValues = DataObject::getGetInheritedValues(); + DataObject::setGetInheritedValues($definition->isEnableInheritance()); + UnpublishedHelper::hideUnpublished( function () use ($definition, $params, $total, $fetcher, $provider, $fetcherContext) { $count = 0; @@ -180,6 +184,8 @@ function () use ($definition, $params, $total, $fetcher, $provider, $fetcherCont }, false === $definition->isFetchUnpublished() ); + + DataObject::setGetInheritedValues($getInheritedValues); } private function exportRow( diff --git a/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php b/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php index 7ffa436f..95764898 100644 --- a/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php +++ b/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php @@ -52,6 +52,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add('runner', ExportRunnerChoiceType::class) ->add('name', TextType::class) ->add('stopOnException', CheckboxType::class) + ->add('enableInheritance', CheckboxType::class) ->add('fetchUnpublished', CheckboxType::class) ->add('failureNotificationDocument', IntegerType::class) ->add('successNotificationDocument', IntegerType::class) diff --git a/src/DataDefinitionsBundle/Model/ExportDefinition.php b/src/DataDefinitionsBundle/Model/ExportDefinition.php index 8edb9ef9..bf11ad7f 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinition.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinition.php @@ -21,6 +21,11 @@ */ class ExportDefinition extends AbstractDataDefinition implements ExportDefinitionInterface { + /** + * @var bool + */ + public $enableInheritance = true; + /** * @var string */ @@ -54,6 +59,22 @@ public static function getByName($id) return $definitionEntry; } + /** + * @param bool $enableInheritance + */ + public function setEnableInheritance(bool $enableInheritance): void + { + $this->enableInheritance = $enableInheritance; + } + + /** + * @return bool + */ + public function isEnableInheritance(): bool + { + return $this->enableInheritance; + } + public function getFetcher() { return $this->fetcher; diff --git a/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php b/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php index f88fa881..ef15b1d4 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php @@ -121,6 +121,7 @@ public function save() 'mapping', 'runner', 'stopOnException', + 'enableInheritance', 'fetchUnpublished', 'failureNotificationDocument', 'successNotificationDocument', diff --git a/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php b/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php index 96dc6f28..7239c17e 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php @@ -18,6 +18,16 @@ interface ExportDefinitionInterface extends DataDefinitionInterface { + /** + * @param bool $enableInheritance + */ + public function setEnableInheritance(bool $enableInheritance): void; + + /** + * @return bool + */ + public function isEnableInheritance(): bool; + /** * @return mixed */ diff --git a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml index 30e861c6..e131cfec 100755 --- a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml +++ b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml @@ -2,6 +2,10 @@ Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition: exclusion_policy: ALL xml_root_name: export_definition properties: + enableInheritance: + expose: true + type: boolean + groups: [Detailed] fetcher: expose: true type: string diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js index 1e1b2799..cd0dd0d5 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js @@ -124,6 +124,12 @@ pimcore.plugin.datadefinitions.export.item = Class.create(pimcore.plugin.datadef name: 'stopOnException', checked: this.data.stopOnException }, + { + fieldLabel: t('data_definitions_enable_inheritance'), + xtype: 'checkbox', + name: 'enableInheritance', + checked: this.data.enableInheritance + }, { fieldLabel: t('data_definitions_fetcher_objects_unpublished'), xtype: 'checkbox', diff --git a/src/DataDefinitionsBundle/Resources/translations/admin.en.yml b/src/DataDefinitionsBundle/Resources/translations/admin.en.yml index f784385e..3c577562 100644 --- a/src/DataDefinitionsBundle/Resources/translations/admin.en.yml +++ b/src/DataDefinitionsBundle/Resources/translations/admin.en.yml @@ -44,6 +44,7 @@ data_definitions_filter: 'Filter' data_definitions_runner: 'Runner' data_definitions_create_version: 'Create new Version on every Run' data_definitions_stop_on_exception: 'Stop on Exception' +data_definitions_enable_inheritance: 'Enable Inheritance' data_definitions_installed: 'ImportDefinitions has been installed' data_definitions_uninstalled: 'ImportDefinitions has been uninstalled' data_definitions_success_document: 'Success Notification Document'