When i had migrated to uCommerce 2.0.1 i started expiriencing problems with creating Product.
We are using some WCF service where we are getting information about products, then i need to import all products to uCommerce. Now you set Id in Product class as read-only property, i thought you are resolving Id in auto mode, but seems that no....
Look to my code:
Product product = new Product
{
Sku = i.no,
Name = i.description,
AllowOrdering = true,
DisplayOnSite = i.blocked.ToLower() != "no",
ProductDefinition = definition, // Set to an existing defintion
ThumbnailImageMediaId = null // ID from Umbraco (nullable int)
};
product.Save();
And i am getting this error:
could not resolve property: Id of:
UCommerce.EntitiesV2.ProductDefinition
[.SingleOrDefault[UCommerce.EntitiesV2.ProductDefinition](NHibernate.Linq.NhQueryable`1[UCommerce.EntitiesV2.ProductDefinition],
Quote((d, ) => (Equal(d.Id, p1))), )]
Yes, seems, that problem was not in that part. Our team had figured out, that SingleOrDefault(<lambda expression>) method works not in all cases, sometime, it just returns null. And we prefer to use Find(<lambda expression>) which works all the time for us. Anyway thanks for help :-)
Glad to hear that you figured it out. It would be extremely helpful if you could post the code for a repro so we can take a look at it and fix any issue there might be with the API. Thanks in advance.
Im trying to create a product programmatically but it is not allowing me to set 'ProductDefinitionId' . Im using using Ucommerce 2.6. Its showing the following error
"Set accessor of property ProductDefinition is not accessible "
my code is
Dim Prod As New Product
With Prod .Sku = "abc" .Name = "abc" .AllowOrdering = True .DisplayOnSite = True Prod.ProductDefinition.ProductDefinitionId = 23 // this line throws the error End With
Could u please let me know where the error and share any articles to create product programmatically
Problem creating product from API
Hello again :-)
When i had migrated to uCommerce 2.0.1 i started expiriencing problems with creating Product.
We are using some WCF service where we are getting information about products, then i need to import all products to uCommerce. Now you set Id in Product class as read-only property, i thought you are resolving Id in auto mode, but seems that no....
Look to my code:
And i am getting this error:
could not resolve property: Id of: UCommerce.EntitiesV2.ProductDefinition [.SingleOrDefault[UCommerce.EntitiesV2.ProductDefinition](NHibernate.Linq.NhQueryable`1[UCommerce.EntitiesV2.ProductDefinition], Quote((d, ) => (Equal(d.Id, p1))), )]
Hi Igor,
Your code looks right. In fact I've got a unit test with your exact code.
The problem must be somewhere else. One thing to try is grabbing the product definition id using this code:
Yes, seems, that problem was not in that part. Our team had figured out, that SingleOrDefault(<lambda expression>) method works not in all cases, sometime, it just returns null. And we prefer to use Find(<lambda expression>) which works all the time for us. Anyway thanks for help :-)
Glad to hear that you figured it out. It would be extremely helpful if you could post the code for a repro so we can take a look at it and fix any issue there might be with the API. Thanks in advance.
Hi Soren,
Im trying to create a product programmatically but it is not allowing me to set 'ProductDefinitionId' . Im using using Ucommerce 2.6. Its showing the following error
"Set accessor of property ProductDefinition is not accessible "
my code is
Dim Prod As New Product
With Prod
.Sku = "abc"
.Name = "abc"
.AllowOrdering = True
.DisplayOnSite = True
Prod.ProductDefinition.ProductDefinitionId = 23 // this line throws the error
End With
Could u please let me know where the error and share any articles to create product programmatically
You want to set the product definition itself instead of the ID like so:
Hope this helps.
thanks Soren..it helped me..
is working on a reply...