ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 3 replies, has 2 voices, and was last updated by  Dima Makaruk 2 years ago.

  • Creator
    Topic
  • #11891

    Dima Makaruk
    Participant

    My CSV look like this:

    column1,column2,column3:item:id
    text,text,1

    In this case the collection (column3) is normally denormalized containing one item in collection.
    How is it possible to import more than one item in collection ?

    Something like this :

    column1,column2,column3:item:id
    text,text,1|3|4

    Normalizer method looks like this:

    public function denormalize($data, $class, $format = null, array $context = array())
    {
    if (!is_array($data)) {
    return new ArrayCollection();
    }
    $itemType = $this->getItemType($class);
    if (!$itemType) {
    return new ArrayCollection($data);
    }
    $result = new ArrayCollection();
    foreach ($data as $item) {
    $result->add($this->serializer->denormalize($item, $itemType, $format, $context));
    }
    return $result;
    }

    Where :
    $data = [‘item’ => [‘id’ => ‘1|3|4’]]
    $item = [‘id’ => ‘1|3|4’]

    What actually should look like this

    $data = [[‘id’ => ‘1’],[‘id’ => ‘3’],[‘id’ => ‘4’]]

    Should i use a custom DataConverter before deserialization ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #11892

    Dima Makaruk
    Participant

    The DefaultDataConverter doesn’t check if the value should be an array:

    It look only if the key must be an array for further support of relations when deserializing.

    #11908

    Sergey
    Oro Core
    #11911

    Dima Makaruk
    Participant

    Hi thank you for the tip.
    Somehow i’ve missed the TreeDataConverter class,will try to use it.

    P.S.
    I created additional normalizer for this case it worked.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.