FriendsOfSylius / SyliusImportExportPlugin

Sylius plugin to import / export data
MIT License
118 stars 82 forks source link

Hard-coded ProductImage FQCN overrides Sylius resource plugin config #253

Closed aleho closed 1 year ago

aleho commented 3 years ago

The default Sylius setup provides an "override" for ProductImage:

sylius_core:
    resources:
        product_image:
            classes:
                model: App\Entity\Product\ProductImage

This plugin's configuration hard-codes the model class to be used, leading to all sorts of hard to debug problems (project entity ignored, wrong entity hydrated, collection not instantiated) with code using the sylius.repository.product_image.

Would you consider either not overriding the Sylius service ID, or using the argument '%sylius.model.product_image.class%' instead of the hard coded 'Sylius\Component\Core\Model\ProductImage'?

This works work me, but I'm not sure whether this is the right way to go:

    sylius.class_metadata.product_image:
        class: Doctrine\ORM\Mapping\ClassMetadata
        factory:   ['@doctrine.orm.default_entity_manager' , 'getClassMetadata']
        arguments: ['%sylius.model.product_image.class%']

For reference, this broke another plugin for me webgriffe/SyliusAkeneoPlugin#62.