Hi All,
I am still fairly new to Umbraco and stepping into Merchello.
I am having issues with understanding the Category view and display products within it.
In Merchello you have a category in the shop which can show multiple collections.
I have used fastrack and it basically has the concept of the following:
@foreach (var product in Model.Products)
Which seems to only ever render 10 products and has no pagination knowledge or anything.
I have seen the various forum posts which indicate things like ProductContentQuery but I am struggling to put it together.
If I have the following in my category view:
var productQuery = merchelloHelper.ProductContentQuery().Page(CurrentPage).ItemsPerPage(PageSize);
This will always render all products. So I am trying to work out how I render all products that are in the category. I could get all collection Keys and do a constrain based on those keys? But how do I get those keys?
I am probably missing something obvious so please call me a noob but hopefully someone can point me into the right direction?
Not sure why no one would know but I managed to work things out.
A category and the layout from Fastrack will work fine but the "All Products" will and has a permanent limit of 10 items.
When you access @Model.Products as well it does not have the tools to properly form pagination as you may want a eCommerce site.
SO:
The main parts for the solution to this were:
var productQuery = merchelloHelper.ProductContentQuery().Page(CurrentPage).ItemsPerPage(PageSize).ConstrainByCollectionKey(Model.Products.CollectionKey);
This will setup a paged product output for the category based on the collectionKey.
You would have parameters for your page size and current page based on a URL parameter.
To get a total count of items you could use @Model.Products.Count() but I do not trust it or find info on the limit that may have total.
var totalCount = merchelloHelper.ProductContentQuery().ItemsPerPage(999999).ConstrainByCollectionKey(Model.Products.CollectionKey);
This may not be pretty but this can be used to get the total count to use for the pagination.
The trick is with the "Shop all". If you make a Category that displays all the shop using the default collection provided by Merchello it does not have a collection key and will only show 10 products with Model.Products as mentioned earlier.
I have set a simple if for the Model.Name for my "Shop All" and there set the values differently in this case:
Listing Paginated Products in Category
Hi All, I am still fairly new to Umbraco and stepping into Merchello.
I am having issues with understanding the Category view and display products within it.
I have used fastrack and it basically has the concept of the following:
@foreach (var product in Model.Products)
Which seems to only ever render 10 products and has no pagination knowledge or anything.
I have seen the various forum posts which indicate things like ProductContentQuery but I am struggling to put it together.
If I have the following in my category view:
var productQuery = merchelloHelper.ProductContentQuery().Page(CurrentPage).ItemsPerPage(PageSize);
This will always render all products. So I am trying to work out how I render all products that are in the category. I could get all collection Keys and do a constrain based on those keys? But how do I get those keys?
I am probably missing something obvious so please call me a noob but hopefully someone can point me into the right direction?
Not sure why no one would know but I managed to work things out.
A category and the layout from Fastrack will work fine but the "All Products" will and has a permanent limit of 10 items.
When you access @Model.Products as well it does not have the tools to properly form pagination as you may want a eCommerce site.
SO:
The main parts for the solution to this were:
This will setup a paged product output for the category based on the collectionKey. You would have parameters for your page size and current page based on a URL parameter.
To get a total count of items you could use @Model.Products.Count() but I do not trust it or find info on the limit that may have total.
This may not be pretty but this can be used to get the total count to use for the pagination.
The trick is with the "Shop all". If you make a Category that displays all the shop using the default collection provided by Merchello it does not have a collection key and will only show 10 products with Model.Products as mentioned earlier. I have set a simple if for the Model.Name for my "Shop All" and there set the values differently in this case:
From here I been able to effectively build paginated product catalogues for a store and they render quite quickly.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.