Is there a way to display the prices for all of a product's variants on the category list page?
So it would look like:
Product Name
Product Price
Variant Price
Thanks.
Displaying variant prices on category list page
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
Re: Displaying variant prices on category list page
This code may help you.
Edit the ConLib/CategoryListPage.ascx.cs file and add the following method to it
Now edit the ConLib/CategoryListPage.ascx file and search the CatalogNodeList repeater control and replace with the following code
Now you will see and extra column containing the Variant prices when you refresh the page.
Edit the ConLib/CategoryListPage.ascx.cs file and add the following method to it
Code: Select all
public string GetVariantPrices(Object productId)
{
ProductVariantCollection variants = ProductVariantDataSource.LoadForProduct(AlwaysConvert.ToInt(productId));
StringBuilder result = new StringBuilder();
foreach(ProductVariant pv in variants)
{
result.Append(pv.Price.ToString("ulc"));
result.Append(",");
}
if (result.Length > 0)
result.Remove((result.Length - 1), 1);
return result.ToString();
}
Code: Select all
<asp:Repeater ID="CatalogNodeList" runat="server" OnItemDataBound="CatalogNodeList_ItemDataBound" EnableViewState="false">
<HeaderTemplate>
<table class="pagedList" style="width: 100%;" border="0" cellspacing="1">
<tr>
<th scope="col" align="left">SKU</th>
<th scope="col">Name</th>
<th scope="col">Manufacturer</th>
<th scope="col" style="width: 80px;" align="center">Retail Price</th>
<th scope="col" align="center">Our Price</th>
<th scope="col" align="center">Our Variant Prices</th>
<th scope="col"> </th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<asp:PlaceHolder ID="phItemTemplate1" runat="server"></asp:PlaceHolder>
<td align='center'><uc:ProductPrice ID="Price" runat="server" Product='<%#Eval("ChildObject")%>' /></td>
<td><asp:Label ID="albl" runat="server" Text='<%# GetVariantPrices(Eval("CatalogNodeId")) %>' ></asp:Label> </a </td>
<td><uc:AddToCartLink ID="Add2Cart" runat="server" Product='<%#((CatalogNode)Container.DataItem).CatalogNodeType == CatalogNodeType.Product?((CatalogNode)Container.DataItem).ChildObject:null%>' /></td>
<asp:PlaceHolder ID="phItemTemplate2" runat="server"></asp:PlaceHolder>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:PlaceHolder ID="PagerPanel" runat="server">
<div class="paging">
<asp:Repeater ID="PagerControls" runat="server" OnItemCommand="PagerControls_ItemCommand" EnableViewState="true">
<ItemTemplate>
<asp:LinkButton ID="PageLink" runat="server" Text='<%#Eval("Text")%>' CommandName="Page" CommandArgument='<%#Eval("PageIndex")%>' Enabled='<%#Eval("Enabled")%>'></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>

Visit the links below to Download Plugins for your AC7 Store
http://www.plugables.com
http://blog.plugables.com