Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8: Unable to get all content of a certain type using GetPagedOfType() #4973

Closed
hartviglarsen opened this issue Mar 13, 2019 · 2 comments
Closed

Comments

@hartviglarsen
Copy link
Contributor

hartviglarsen commented Mar 13, 2019

I was playing around with getting all content of a certain type. In V7 the ContentService had GetContentOfContentType(), however that does not exist in V8. Therefore I decided to try and be creative with GetPagedOfType(). Unfortunately the collection returned does not contain any items.

Reproduction

var productTypeId = Product.GetModelContentType().Id;
var products = _contentService.GetPagedOfType(productTypeId, 1, 9999, out var size, null);

Expected result

I expect that products contains a collection of products (if there are any) and that size contains the amount of records.

Actual result

While size does show the correct amount of records, the collection does not contain any products.

image

@Shazwazza
Copy link
Contributor

It's because you are passing in 1 for the pageIndex parameter. Being an index it is zero based. So you are asking for page #2 by passing in 1 and you only have 2 records.

pass in 0 for the page index and it should work

@bergmania
Copy link
Member

Could have been nice to just request using something like
var products = _contentService.GetPagedOfType(productTypeId, PagingInfo.AllItems, out var size, null);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants