Is there any way to create a collection under Products Manually using code?
Currently I am using IEntityCollectionsService as so.
var collection = this.MerchelloServices.EntityCollectionService.CreateEntityCollectionWithKey(EntityType.Product, Guid.NewGuid(), "Iconic Collection");
this.MerchelloServices.EntityCollectionService.Save(collection);
it saves into the EntityCollectionsTable in the database and doesn't appear under Products even though the entity type set is products, also when I refresh Merchello, its deleted from the table. Anyone have any idea on how to manually create a collection?
If you don't mind, I would also like to know how to create child collections, I tried using the collection keys create above as the provider key with no success
currently I have:
foreach (var subCollection in sec.Subsections) {
var sub = this.MerchelloServices.EntityCollectionService.CreateEntityCollectionWithKey(EntityType.Product, collection.Key, subCollection.Name);
this.MerchelloServices.EntityCollectionService.Save(sub);
}
I had hoped there would be a createChildCollection method against the collection
How to create collections under Products using code
Is there any way to create a collection under Products Manually using code? Currently I am using IEntityCollectionsService as so.
it saves into the EntityCollectionsTable in the database and doesn't appear under Products even though the entity type set is products, also when I refresh Merchello, its deleted from the table. Anyone have any idea on how to manually create a collection?
I believe it has to do with the Guid.NewGuid().
If you change it to:
it should work I think.
Puck
Thank you so much, I was battling with this all weekend, who would have thought this is all it took
Great to hear! Glad I was able to help
If you don't mind, I would also like to know how to create child collections, I tried using the collection keys create above as the provider key with no success
currently I have:
I had hoped there would be a createChildCollection method against the collection
Basically what you have to do, is create a second collection, and pass the ParentKey to that collection.
So in short:
That should do it
Hello,
I tried the exact code below, but when I go and find the new collection, I am getting this error :
Any help would much be appreciated what I am doing wrong.
is working on a reply...