Hi,
When implement Catalog content provider, we used some hacks as follow:
- If an entry is active (IsAvailable = true), then it's published. Otherwise it's not.
- The StartDate = Start publishing, EndDate = Stop publishing.
Yes, it's not optimal and a bit confusing, but for now you can check if status of a entry content is published or not to see if it's active or not.
Regards.
/Q
HI Khurram
Hope you are doing well. I had a quick favour to ask. I have just started working in depth on the latest version of EPiserver commerce..
On a CMS page I want to be able to link to a product.
For this I am using the "Url to Page" property.
This works fine and retrieves the url to the product page. However I do not want to redirect to that page but actually just get the product name out. Am I using the correct CMS property.
In general if I want to get a fashion product out using the product code I use something like below
var contentLink = ExtensionMethods.ReferenceConverter.Service.GetContentLink("Tops-Tunics-CowlNeck", CatalogContentType.CatalogEntry);
var fashionProductContent = (FashionProductContent)ExtensionMethods.ContentLoader.Service.Get<IContent>(contentLink);
But I only have a link. Am I using the correct property.
Regards
Sandeep
Hi,
Sandeep, Glad to see you again, btw congratulations on the birth of your newborn son.
If i am not understanding wrong, this can help you
var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>(); [Editted]
var content = urlResolver.Route(url);
Regards
Khurram
HI Khurram
Thanks for your wishes. Have you got some code to create a product using content provider in code.
Regards
Sandeep
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
//Create a new instance of CatalogContentTypeSample that will be a child to the specified parentNode.
var newSku = contentRepository.GetDefault<CatalogContentTypeSample>(linkToParentNode);
//Set some required properties.
newSku.Description = "Great";
//Publish the new content and return its ContentReference.
return contentRepository.Save(newSku, SaveAction.Publish, AccessLevel.NoAccess);
/K
Hi Khurram Bhai
Thanks once again. Works perfectly. Used the same logic to create catalog, products and variants. All works like a charm.
Kind Regards
Sandeep
Hi Khurram
Could you please let me know how to creare a catalog from code too. The same method does not seem to work. It seems to complain we need an implementation of "ICatalogContentCommitter".
Kind Regards
Hi Khurram
Found a solution. Aparently this was not supported in version 7.5. In Episerver Version 7.9 and above you can do it using the following. Please note the default properties below are mandatory -
var repository = ServiceLocator.Current.GetInstance<IContentRepository>(); var referenceConverter = ServiceLocator.Current.GetInstance<Mediachase.Commerce.Catalog.ReferenceConverter>(); var root = referenceConverter.GetRootLink(); var catalog = repository.GetDefault<CatalogContent>(root); catalog.Name = "My catalog2"; catalog.DefaultCurrency = "USD"; catalog.DefaultLanguage = "en"; catalog.WeightBase = "Pounds"; repository.Save(catalog, SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);
Kind Regards
Sandeep
Yes, CatalogContent wasn't supported until recently - IIRC it was added in 7.9 as you pointed out.
Please note that for your own question, you should create another thread to keep all discussions focused.
Thanks.
/Q
Hi Quan
Thanks for your reply. Had realised that and hence I deleted the question from your post and created a new thread for it. Have posted the solution on here also just in case some one read this and wondered if we got to the solution.
Regards
Sandeep
My current ecommerce solution needs to support multiple market, i'd like to implement some business rule to prevent commerce editor publishing the product in the selected market without having price configured correctly.
What will be the best way to check the product availability?
P. s. I am using the latest commerce 9.10
Hi,
Example:
I store an item in recently viewied block(cookies involved)
Product has been disabled But still vcan be retrived in recently viewed block.
UrlResolver.Current.GetUrl(contentLink, language) will throw an exception if prodct is not active.
IN CMS 7.5 without involving DB how can I check product is active or NOT.
[product.LoadEntry().IsActive return me is-active but involves a db trip]
var productContent = (ProductContent)contentLoader.Get(contentLink)
productConten.Status is coming as "CheckedOut"
any idea?
Regards
/K