Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

How to import XML data in a dataobject?

Go to End

10 Posts   3122 Views


Community Member, 5 Posts

13 September 2011 at 6:18am

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:

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.


Community Member, 7 Posts

13 September 2011 at 7:19pm

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 ?

Go to Top