pimcore-data-definitions
pimcore-data-definitions copied to clipboard
Configuration of ImportDefinition is returned when getting ExportDefinition by ID
| 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?
How do you use the getByName functions? Can you give me some examples?
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');
In my Functional Codeception tests i'm using:
/** @var DefinitionRepository $exportRepository */
$exportRepository = $this->grabService('data_definitions.repository.export_definition');
Ok, that will help, I'll give a test sometime this week?
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
The repository and the dao looks fine.
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 was just checking too, yes, you are right. Do want to make a PR to change that?
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 👍
Closed since it's fixed with #427