How to find total number of product in a particular page.

Pritam Gupta asked on January 25, 2016 14:33

Hello,

I have a Three product type like Product1,Product2,Product3 in a product page. In that have some product.Now have to display that details in home page so i used one repeater at home page to display details

<div class="col-sm-6 col-md-4"><!-- category -->
                        <div class="box-content thumbnail text-center">
                            <a href="<%# GetDocumentUrl() %>" class="item-image"><!-- image -->
                                <img class="img-responsive" src="<%# GetFileUrl("MenuItemTeaserImage") %>" alt="<%# Eval("DocumentName",true) %>">
                            </a>
                            <div class="caption text-left"><!-- name -->
                                <h5 class="nomargin elipsis"><%# Eval("DocumentName") %> (<%# DataRowView.DataView.Count %>)</h5>
                            </div>
                        </div>
                    </div><!-- /category -->

I used DataRowView.DataView.Count but it display only 3. so how can i display a number of product in a particular a product type. 

Correct Answer

Brenden Kehren answered on January 25, 2016 16:57

So if I understand correctly your home page displays products from another location in the content tree. What you want to do is display the total products under that other location in the content tree and not just the 3 on the home page. Assuming each of the items in the repeater is a different page type, you could use something like this:

CMS.DocumentEngine.DocumentHelper.GetDocuments(Eval("ClassName")).Path(Eval("NodeAliasPath")).Published().Count
1 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.