pimcore-data-definitions icon indicating copy to clipboard operation
pimcore-data-definitions copied to clipboard

Configuration of ImportDefinition is returned when getting ExportDefinition by ID

Open paulverdu opened this issue 1 year ago • 9 comments

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Branch? 5.1.1

I'm currently working on upgrading a project to Pimcore 11 and i'm facing an issue where Import and ExportDefinitions are not correctly returned.

When running the list command for exports and import i'm correctly seeing all the exports and imports and their corresponding id's, but when running my Functional tests and getting exports by name, it's not find them. When getting the exports by id, I do get an instance of ExportDefinition but with all the configurations, including mapping of the import definition with the corresponding id. I've ran the convert php to yaml commands and made sure they all have an id again.

I have an ExportDefinition with id 7 called 'Tech Mapping' and an ImportDefinition with id 7 called 'Washing Instruction'. When finding export with name, I get the exception "Export Definition with Name "Tech Mapping" does not exist.". When find export with id 7, I get an ExportDefinition with all the data from the ImportDefinition 'Washing Instructions'.

I've never had this problem. Am I missing something?

paulverdu avatar Oct 28 '24 07:10 paulverdu

How do you use the getByName functions? Can you give me some examples?

dpfaffenbauer avatar Oct 28 '24 07:10 dpfaffenbauer

Hi @dpfaffenbauer. Thanks for the super fast response!

I'm either using:

\Instride\Bundle\DataDefinitionsBundle\Model\ExportDefinition::getByName('Tech Mapping');

But also importing data_definitions.repository.export_definition as a service in my classes like:

    App\ProductPriceBundle\MessageHandler\ExportB2bPricesHandler:
        arguments:
            - '@data_definitions.repository.export_definition'
            - '@Instride\Bundle\DataDefinitionsBundle\Exporter\ExporterInterface'

And then using $this->repository->getByName('Tech Mapping');

paulverdu avatar Oct 28 '24 08:10 paulverdu

In my Functional Codeception tests i'm using:

/** @var DefinitionRepository $exportRepository */
$exportRepository = $this->grabService('data_definitions.repository.export_definition');

paulverdu avatar Oct 28 '24 08:10 paulverdu

Ok, that will help, I'll give a test sometime this week?

dpfaffenbauer avatar Oct 28 '24 08:10 dpfaffenbauer

Thanks. I will see if I can find the problem in the bundle my self in the meantime. I think there is something weird going on somewhere. ImportDefinitions work correctly

paulverdu avatar Oct 28 '24 08:10 paulverdu

Scherm­afbeelding 2024-10-28 om 09 13 54

The repository and the dao looks fine.

paulverdu avatar Oct 28 '24 08:10 paulverdu

Hi @dpfaffenbauer

It seems the caching mechanism in vendor/pimcore/pimcore/lib/Model/Dao/PimcoreLocationAwareConfigDao.php is not correctly working with the bundle. self::cache returns all the ImportDefinitions instead of the ExportDefinitions.

So self::$cache[$this->settingsStoreScope][$id] returns the ExportDefinitions. I can see $this->settingsStoreScope is returning data_definitions, but should this be data_definitions.export and data_definitions.import? To differentiate Exports and Imports?

paulverdu avatar Oct 28 '24 08:10 paulverdu

@paulverdu was just checking too, yes, you are right. Do want to make a PR to change that?

dpfaffenbauer avatar Oct 28 '24 08:10 dpfaffenbauer

Just changed the code to add the config key from each individual Dao to the settingsStoreScope value. Testing it now and will create a PR 👍

paulverdu avatar Oct 28 '24 08:10 paulverdu

Closed since it's fixed with #427

paulverdu avatar Nov 25 '24 08:11 paulverdu