コード例 #1
0
 /// <summary>
 /// Creates <see cref="IProductContent"/> from the display object.
 /// </summary>
 /// <param name="display">
 /// The display.
 /// </param>
 /// <returns>
 /// The <see cref="IProductContent"/>.
 /// </returns>
 public static IProductContent AsProductContent(this ProductDisplay display)
 {
     if (!display.HasVirtualContent()) return null;
     var factory = new ProductContentFactory();
     return factory.BuildContent(display);
 }
コード例 #2
0
ファイル: MerchelloHelper.cs プロジェクト: EricMunn/Merchello
        /// <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);
        }
コード例 #3
0
 //// 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;
 }
コード例 #4
0
        /// <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>
 /// 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();
 }