data-import icon indicating copy to clipboard operation
data-import copied to clipboard

How to deal with a ManyToMany Relationship ?

Open numerogeek opened this issue 10 years ago • 0 comments

Hi guys,

This bundle looks very great but I have some questions about some implementation.

First I have implemented an XmlReader to convert an XML files. The XML file look like :

<?xml version="1.0" encoding="UTF-8"?>
<brands>
    <brand>
        <brand_name>Whatever the brand is</brand_name>
        <cost>100</costcost>
        <categories>
            <category>
                <categoryCode>CAT001</categoryCode>
            </category>
            <category>
                <categoryCode>CAT003</categoryCode>
            </category>
    </categories>
    </brand>
</brands>

I have two entity : brand & categories, with a ManyToMany relationship between them.

Second I have created a customDoctrineWriter (which looks like this one from @intrepion: https://github.com/ddeboer/data-import/pull/124/files )

But I keep having errors. the loadAssociationObjectsToEntity seems to get a Proxies which can't be saved in addCategory. (Entity not found error)

Could you please show me an example of implementation with ManyToMany realtionship, and maybe what the reader should return to get it working (supposing the tagName in xml are the field's name in the entity)

thanks !

numerogeek avatar Aug 09 '15 12:08 numerogeek