public static IProductContent AsProductContent(this ProductDisplay display, ProductContentFactory factory) { if (!display.HasVirtualContent()) { return(null); } return(factory.BuildContent(display)); }
/// <summary> /// The typed product content from collection. /// </summary> /// <param name="collectionKey"> /// The collection key. /// </param> /// <returns> /// The <see cref="IEnumerable{IProductContent}"/>. /// </returns> public IEnumerable <IProductContent> TypedProductContentFromCollection(Guid collectionKey) { var products = Query.Product.GetFromCollection(collectionKey, 1, long.MaxValue).Items .Select(x => (ProductDisplay)x) .Where(x => x.Available && x.DetachedContents.Any(y => y.CanBeRendered)); var factory = new ProductContentFactory(); return(products.Select(factory.BuildContent)); }
/// <summary> /// The typed product content from collection. /// </summary> /// <param name="collectionKey"> /// The collection key. /// </param> /// <param name="page"> /// The current page. /// </param> /// <param name="itemsPerPage"> /// The items Per Page. /// </param> /// <param name="sortBy"> /// The sort field (valid values are "sku", "name", "price"). /// </param> /// <param name="sortDirection"> /// The sort direction. /// </param> /// <returns> /// The <see cref="IEnumerable{IProductContent}"/>. /// </returns> public IEnumerable <IProductContent> TypedProductContentFromCollection(Guid collectionKey, long page, long itemsPerPage, string sortBy = "", SortDirection sortDirection = SortDirection.Ascending) { if (page <= 0) { page = 1; } var products = Query.Product.GetFromCollection(collectionKey, page, itemsPerPage, sortBy, sortDirection) .Items.Select(x => (ProductDisplay)x) .Where(x => x.Available && x.DetachedContents.Any(y => y.CanBeRendered)); var factory = new ProductContentFactory(); return(products.Select(factory.BuildContent)); }
///// <summary> ///// Example shipment shipped / delivered notification handler ///// </summary> ///// <param name="sender"> ///// The sender. ///// </param> ///// <param name="e"> ///// The <see cref="StatusChangeEventArgs{IShipment}"/> ///// </param> //private void ShipmentServiceStatusChanged(IShipmentService sender, StatusChangeEventArgs<IShipment> e) //{ // var validKeys = new[] // { // Core.Constants.DefaultKeys.ShipmentStatus.Delivered, // Core.Constants.DefaultKeys.ShipmentStatus.Shipped // }; // foreach (var shipment in e.StatusChangedEntities) // { // if (!validKeys.Contains(shipment.ShipmentStatus.Key)) continue; // LogHelper.Info<UmbracoEventHandler>(string.Format("Raising notification trigger for shippment no. {0}", shipment.ShipmentNumber)); // Notification.Trigger("OrderShipped", shipment, Core.Observation.Topic.Notifications); // } //} //// Event handler methods /// <summary> /// Handles the <see cref="ProductContentFactory"/> on initializing event. /// </summary> /// <param name="sender"> /// The <see cref="ProductContentFactory"/>. /// </param> /// <param name="e"> /// The <see cref="VirtualContentEventArgs"/>. /// </param> /// <remarks> /// This is required to set the parent id of the virtual content /// </remarks> private static void ProductContentFactoryOnInitializing(ProductContentFactory sender, VirtualContentEventArgs e) { var store = ExampleUiHelper.Content.GetStoreRoot(); e.Parent = store; }
/// <summary> /// Creates <see cref="IProductVariantContent"/> from the display object. /// </summary> /// <param name="display"> /// The display. /// </param> /// <param name="factory"> /// The factory. /// </param> /// <returns> /// The <see cref="IProductVariantContent"/>. /// </returns> public static IProductVariantContent AsProductContent(this ProductVariantDisplay display, ProductContentFactory factory) { if (!display.DetachedContents.Any(x => x.CanBeRendered)) { return(null); } return(factory.BuildContent(display)); }
/// <summary> /// Sets the parent of Merchello virtual product content to the Home node. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private static void ProductContentFactoryOnInitializing(ProductContentFactory sender, VirtualContentEventArgs e) { e.Parent = ContentResolver.Instance.GetRootContent(); }