Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are many ways to code for Kentico. I personally find the API is a bit clunky and on quite a few occasions I was surprised that a method didn't exist requiring extra calls to get the required results. I do use the Kentico API more when putting data in to Kentico. Pulling it out I use the following.</p> <p>STORED PROC</p> <p>Write a SQL stored procedure to get the top X categories - GetTop5Categories.</p> <p>Look at the COM_* tables, specifically COM_OrderItem, linking OrderItemSKUID back to COM_SKU (or View_COM_SKU_Joined if you need to get to the IA).</p> <p>This will get you the top selling products with a group by, a count, a top X and an order by. </p> <p>Then you can link to other tables such as CMS_Category or CMS_Document (depending on how you setup your categories). The bonus of this is that procs are compiled, you do all your data manipulation there (it's what MSSQL specialises in!) and you only send back what you need to in the result set.</p> <p>DOMAIN (leveraging EF)</p> <p>I usually create a separate class library project myproject.domain and put an Entity Framework edmx in there mapped back to the Kentico DB. Add the proc to the EDMX, then create a Function Import MyProject_GetTop5Categories from your newly imported proc.</p> <p>WEB</p> <p>add a reference to the domain project from your web project, and a 'using at the top of the codebehind of the control. </p> <p>using myproject.domain;</p> <p>then in Page_Load for the control:</p> <p>...</p> <pre><code>if(!IsPostBack) { var entities = new MyProjectModelContainer(); var list = entities.MyProject_GetTop5Categories().ToList(); StringBuilder sb = new StringBuilder("&lt;ul&gt;"); foreach(var category in list) { sb.Append("&lt;li&gt;&lt;a href='"+category.Link+"'&gt;" + category.Name + "&lt;/a&gt;&lt;/li&gt;"); } sb.Append("&lt;ul&gt;"); listPlaceHolder = sb.ToString(); } </code></pre> <p>handwritten so probably a typo or two in there :)</p> <p>HTH</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload