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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

How to import XML data in a dataobject?


Go to End


10 Posts   4202 Views

Avatar
neglostyti

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: http://pastebin.com/CMjA6epG

How it looks in admin:
http://img3.imageshack.us/img3/537/adminmenu.png

What was inserted:
http://img220.imageshack.us/img220/4316/datapv.png

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.

Avatar
kpower

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();
$img->CMSThumbnail();
$img->updateFilesystem();
                                       
$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