I am struggeling with importing products in Vendr shop.
Problem is as described here that the price is not imported due to the underlying data structure in Vendr where a price value is bound to the currency (as Guid).
So the data structure of a price field in Vendr is:
Chatting with Matt Brailsford he recommended to post the issue here.
So here is the class that I have come up with so far:
using CMSImport.Extensions.Providers.FieldProviders;
using CMSImport.Extensions.Providers.ImportProviders;
using Umbraco.Core.Services;
namespace CampusShop.Core.Controllers
{
public class CurrencyFieldProvider :IFieldProvider
{
private readonly IContentService _contentService;
public CurrencyFieldProvider(IContentService contentService)
{
_contentService = contentService;
}
public object Parse(object value, ImportPropertyInfo property, FieldProviderOptions fieldProviderOptions)
{
//EXAMPLE CODE PLEASE ??? FOR EXAMPLE
var price = Decimal.Parse(value.AsString());
var data = new Dictionary<string, decimal> {
{ "6FD40872-83A8-473E-9DE4-F1305049F8D9", price }
};
return JsonConvert.SerializeObject(data);
}
}
}
The above code is just a rough guess of how it could work.
Can anyone please help me out with some example code for this?
This rang a bell with me so I went looking for the code. It turns out I cheated and did this in Excel, then imported using CMS Import. Sorry it doesn't answer your question, but after searching for this I couldn't just ignore it,
I don't recall anything special. I might have had the field as a text field when I did the import, then changed it to a price field once the data was in place. Worth a try if you have a minute,
Not sure where the GUID comes from but the extra quites is propablyu because it's a string object.
Can't you make a simple class that holds a GUID and Decimal value. Fill a list of these objects and serialize those to string in the end of the FieldProvider?
Custom field for import prices in Vendr
Hi there,
I am struggeling with importing products in Vendr shop. Problem is as described here that the price is not imported due to the underlying data structure in Vendr where a price value is bound to the currency (as Guid).
So the data structure of a price field in Vendr is:
Chatting with Matt Brailsford he recommended to post the issue here. So here is the class that I have come up with so far:
The above code is just a rough guess of how it could work. Can anyone please help me out with some example code for this?
Thank you so much.
This rang a bell with me so I went looking for the code. It turns out I cheated and did this in Excel, then imported using CMS Import. Sorry it doesn't answer your question, but after searching for this I couldn't just ignore it,
regards
t
Hi Tom,
thank you very much for this workround. This would save me for now.
Unfortunately, it does not work for me.
I double checked that I have used the syntax the same way as it was in your example:
Do I have to take care of something special?
I don't recall anything special. I might have had the field as a text field when I did the import, then changed it to a price field once the data was in place. Worth a try if you have a minute,
regards
t
I tried changing Vendr.Price to Textstring before Import and changed it back afterwards without success.
But I recognized that the imported value got changed from:
to
I than removed the quotation marks but it did not work either.
How can I prevent the extra quotation marks that get generated?
I now changed the Guid to lower case.
That did the trick. It works now.
Thanks to everyone and have a funky friday ;)
Even better :-) Have a good Friday
Thanks Tom an Hi Edgar,
Not sure where the GUID comes from but the extra quites is propablyu because it's a string object.
Can't you make a simple class that holds a GUID and Decimal value. Fill a list of these objects and serialize those to string in the end of the FieldProvider?
Best,
Richard
Hi Edgar,
glad you got it working,
t
helped, thanks everyone)
Edgar,
I know you got this working, however, this is how I accomplished this without having too modify my csv file (my file holds just a price)
See this Link
is working on a reply...