Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » How to import XML data in a dataobject?

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 1710 Views
  • neglostyti
    Community Member
    5 Posts

    Re: How to import XML data in a dataobject? Link to this post

    Thanks, kpower, it was really helpful. Now I can 'upload' images, but there is another problem - after I upload many items, on admin panel I can only see few of them. And their status are deleted(or smth like that).

    I checked few times data on database - records are there(only in catalog_live, product_live and sitetree_live tables), ParendID is correct.

    I was played with doPublish() and ->Status = 'Publish' but it doesn't helped.

    My code is here: http://pastebin.com/CMjA6epG

    How it looks in admin:

    What was inserted:

    As you can see, I can not see products under the `Spodnie`;

    In total, there is about 2500 products. If I add all of them, then I can not see products at all, even full tree up to the products.

    The code doesn't look very nice, I know, but this migration i will use only once.

    Any ideas? Thank you for any help.

  • kpower
    Community Member
    7 Posts

    Re: How to import XML data in a dataobject? Link to this post

    Sorry, I can't see any image by going through the links you posted. Also showing the whole code doesn't help. In future, please isolate the code in which you think the problem actually resides

    Considering the following code fragment:

    $do = new Product();
    $do->ParentID = $pid;

    $img = new Image();
    $img->setFilename(ASSETS_DIR . '/images/' . $image . '.jpg');
    $img->Title = $data['name'];
    $imgID = $img->write();

    $imgStr = 'Photo' . ($i+1) . 'ID';
    $do->{$imgStr} = $imgID;

    I'm not sure what this "Product" is, but I guess it's your DataObject. If that is, can you let us know what you expected to do with the last two statements? Were you perhaps trying to add the created Image to the Product, as Product has one-to-many relationship with Image ?

Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.