Just realized it cut my code off so there is a text size limit per post. Here is the next section:
OK now I added a new ascx file in Templates/Categories/ called ProductsKuraray.ascx but again you can name it what you wish.
Here is the ascx code to ProductsKuraray.ascx:
<%@ Control Language="C#" AutoEventWireup="true" Inherits="NopSolutions.NopCommerce.Web.Templates.Categories.ProductsKuraray"
CodeBehind="ProductsKuraray.ascx.cs" %>
<%@ Register TagPrefix="nopCommerce" TagName="ProductBox3" Src="~/Modules/ProductBox3.ascx" %>
<%@ Register TagPrefix="nopCommerce" TagName="PriceRangeFilter" Src="~/Modules/PriceRangeFilter.ascx" %>
<%@ Register TagPrefix="nopCommerce" TagName="ProductSpecificationFilter" Src="~/Modules/ProductSpecificationFilter.ascx" %>
<div class="category-page">
<% if (this.SettingManager.GetSettingValueBoolean("Media.CategoryBreadcrumbEnabled"))
{ %>
<div class="breadcrumb">
<a href='<%=CommonHelper.GetStoreLocation()%>'>
<%=GetLocaleResourceString("Breadcrumb.Top")%></a> /
<asp:Repeater ID="rptrCategoryBreadcrumb" runat="server">
<ItemTemplate>
<a href='<%#SEOHelper.GetCategoryUrl(Convert.ToInt32(Eval("CategoryId"))) %>'>
<%#Server.HtmlEncode(Eval("LocalizedName").ToString())%></a>
</ItemTemplate>
<SeparatorTemplate>
/
</SeparatorTemplate>
</asp:Repeater>
<br />
</div>
<div class="clear">
</div>
<% } %>
<div class="category-description">
<asp:Literal runat="server" ID="lDescription"></asp:Literal>
</div>
<div class="clear">
</div>
<div class="sub-category-grid">
<asp:DataList ID="dlSubCategories" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
RepeatLayout="Table" OnItemDataBound="dlSubCategories_ItemDataBound" ItemStyle-CssClass="item-box">
<ItemTemplate>
<div class="sub-category-item">
<h2 class="category-title">
<asp:HyperLink ID="hlCategory" runat="server" />
</h2>
<div class="picture">
<asp:HyperLink ID="hlImageLink" runat="server" />
</div>
</div>
</ItemTemplate>
</asp:DataList>
</div>
<div class="clear">
</div>
<asp:Panel runat="server" ID="pnlFeaturedProducts" class="featured-product-grid">
<div class="title">
<%=GetLocaleResourceString("Products.FeaturedProducts")%>
</div>
<div>
<asp:DataList ID="dlFeaturedProducts" runat="server" RepeatColumns="2" RepeatDirection="Horizontal"
RepeatLayout="Table" ItemStyle-CssClass="item-box">
<ItemTemplate>
<nopCommerce:ProductBox3 ID="ctrlProductBox" Product='<%# Container.DataItem %>'
runat="server" />
</ItemTemplate>
</asp:DataList>
</div>
</asp:Panel>
<div class="clear">
</div>
<asp:Panel runat="server" ID="pnlSorting" CssClass="product-sorting">
<%=GetLocaleResourceString("ProductSorting.SortBy")%>
<asp:DropDownList ID="ddlSorting" runat="server" OnSelectedIndexChanged="ddlSorting_SelectedIndexChanged"
AutoPostBack="true" />
</asp:Panel>
<div class="clear">
</div>
<asp:Panel runat="server" ID="pnlFilters" CssClass="product-filters">
<div class="filter-title">
<asp:Label runat="server" ID="lblProductFilterTitle">
<%=GetLocaleResourceString("Products.FilterOptionsTitle")%>
</asp:Label>
</div>
<div class="filter-item">
<nopCommerce:PriceRangeFilter ID="ctrlPriceRangeFilter" runat="server" />
</div>
<div class="filter-item">
<nopCommerce:ProductSpecificationFilter ID="ctrlProductSpecificationFilter" runat="server" />
</div>
</asp:Panel>
<div class="clear">
</div>
<div class="product-grid">
<asp:DataList ID="dlProducts" runat="server" RepeatColumns="1" RepeatDirection="Horizontal"
RepeatLayout="Table" ItemStyle-CssClass="item-box">
<HeaderTemplate>
<div class="order-summary-content">
<table class="cart" width="100%">
<thead>
<tr class="cart-header-row">
<th style="width:75px"></th>
<th style="width:325px">
Product Name
</th>
<th style="width:100px">
Price
</th>
<th style="width:100px">
Quantity
</th>
<th style="width:75px">
</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<nopCommerce:ProductBox3 ID="ctrlProductBox" Product='<%# Container.DataItem %>' runat="server" />
</ItemTemplate>
<FooterTemplate>
</table>
</div>
</FooterTemplate>
</asp:DataList>
</div>
<div class="clear">
</div>
<div class="product-pager">
<nopCommerce:Pager runat="server" ID="productsPager" FirstButtonText="<% $NopResources:Pager.First %>"
LastButtonText="<% $NopResources:Pager.Last %>" NextButtonText="<% $NopResources:Pager.Next %>"
PreviousButtonText="<% $NopResources:Pager.Previous %>" CurrentPageText="Pager.CurrentPage" />
</div>
</div>
Here is the code for ProductsKuraray.ascx.cs:
//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at https://www.nopcommerce.com/License.aspx.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
// See the License for the specific language governing rights and limitations under the License.
//
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
//
// Contributor(s): _______.
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.Categories;
using NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings;
using NopSolutions.NopCommerce.BusinessLogic.Directory;
using NopSolutions.NopCommerce.BusinessLogic.Localization;
using NopSolutions.NopCommerce.BusinessLogic.Media;
using NopSolutions.NopCommerce.BusinessLogic.Products;
using NopSolutions.NopCommerce.BusinessLogic.SEO;
using NopSolutions.NopCommerce.Common.Utils;
using NopSolutions.NopCommerce.BusinessLogic.Infrastructure;
namespace NopSolutions.NopCommerce.Web.Templates.Categories
{
public partial class ProductsKuraray : BaseNopFrontendUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillDropDowns();
BindData();
}
}
protected void FillDropDowns()
{
if (this.SettingManager.GetSettingValueBoolean("Common.AllowProductSorting"))
{
ddlSorting.Items.Clear();
var ddlSortPositionItem = new ListItem(GetLocaleResourceString("ProductSorting.Position"), ((int)ProductSortingEnum.Position).ToString());
ddlSorting.Items.Add(ddlSortPositionItem);
var ddlSortNameItem = new ListItem(GetLocaleResourceString("ProductSorting.Name"), ((int)ProductSortingEnum.Name).ToString());
ddlSorting.Items.Add(ddlSortNameItem);
var ddlSortPriceItem = new ListItem(GetLocaleResourceString("ProductSorting.Price"), ((int)ProductSortingEnum.Price).ToString());
ddlSorting.Items.Add(ddlSortPriceItem);
}
else
{
pnlSorting.Visible = false;
}
}
protected void BindData()
{
var category = this.CategoryService.GetCategoryById(this.CategoryId);
//breadcrumb
rptrCategoryBreadcrumb.DataSource = this.CategoryService.GetBreadCrumb(this.CategoryId);
rptrCategoryBreadcrumb.DataBind();
lDescription.Text = category.LocalizedDescription;
//subcategories
var subCategories = this.CategoryService.GetAllCategoriesByParentCategoryId(category.CategoryId);
if (subCategories.Count > 0)
{
dlSubCategories.DataSource = subCategories;
dlSubCategories.DataBind();
}
else
dlSubCategories.Visible = false;
//featured products
var featuredProducts = category.FeaturedProducts;
if (featuredProducts.Count > 0)
{
dlFeaturedProducts.DataSource = featuredProducts;
dlFeaturedProducts.DataBind();
}
else
{
pnlFeaturedProducts.Visible = false;
}
//price ranges
this.ctrlPriceRangeFilter.PriceRanges = category.PriceRanges;
//page size
int totalRecords = 0;
int pageSize = 50;
if (category.PageSize > 0)
{
pageSize = category.PageSize;
}
//price ranges
decimal? minPrice = null;
decimal? maxPrice = null;
decimal? minPriceConverted = null;
decimal? maxPriceConverted = null;
if (ctrlPriceRangeFilter.SelectedPriceRange != null)
{
minPrice = ctrlPriceRangeFilter.SelectedPriceRange.From;
if (minPrice.HasValue)
{
minPriceConverted = this.CurrencyService.ConvertCurrency(minPrice.Value, NopContext.Current.WorkingCurrency, this.CurrencyService.PrimaryStoreCurrency);
}
maxPrice = ctrlPriceRangeFilter.SelectedPriceRange.To;
if (maxPrice.HasValue)
{
maxPriceConverted = this.CurrencyService.ConvertCurrency(maxPrice.Value, NopContext.Current.WorkingCurrency, this.CurrencyService.PrimaryStoreCurrency);
}
}
//specification filter
var psoFilterOption = ctrlProductSpecificationFilter.GetAlreadyFilteredSpecOptionIds();
//sorting
ProductSortingEnum orderBy = ProductSortingEnum.Position;
if (this.SettingManager.GetSettingValueBoolean("Common.AllowProductSorting"))
{
CommonHelper.SelectListItem(this.ddlSorting, CommonHelper.QueryStringInt("orderby"));
orderBy = (ProductSortingEnum)Enum.ToObject(typeof(ProductSortingEnum), int.Parse(ddlSorting.SelectedItem.Value));
}
var productCollection = this.ProductService.GetAllProducts(this.CategoryId,
0, 0, false, minPriceConverted, maxPriceConverted,
string.Empty, false, pageSize, this.CurrentPageIndex,
psoFilterOption, orderBy, out totalRecords);
if (productCollection.Count > 0)
{
this.productsPager.PageSize = pageSize;
this.productsPager.TotalRecords = totalRecords;
this.productsPager.PageIndex = this.CurrentPageIndex;
this.dlProducts.DataSource = productCollection;
this.dlProducts.DataBind();
}
else
{
this.dlProducts.Visible = false;
this.pnlSorting.Visible = false;
}
}
protected void ddlSorting_SelectedIndexChanged(object sender, EventArgs e)
{
string url = CommonHelper.GetThisPageUrl(true);
url = CommonHelper.ModifyQueryString(url, "orderby=" + ddlSorting.SelectedItem.Value, null);
Response.Redirect(url);
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
ctrlPriceRangeFilter.ExcludedQueryStringParams = productsPager.QueryStringProperty;
ctrlProductSpecificationFilter.ExcludedQueryStringParams = productsPager.QueryStringProperty;
ctrlProductSpecificationFilter.CategoryId = this.CategoryId;
ctrlProductSpecificationFilter.ReservedQueryStringParams = "CategoryId,";
ctrlProductSpecificationFilter.ReservedQueryStringParams += "orderby,";
ctrlProductSpecificationFilter.ReservedQueryStringParams += ctrlPriceRangeFilter.QueryStringProperty;
ctrlProductSpecificationFilter.ReservedQueryStringParams += ",";
ctrlProductSpecificationFilter.ReservedQueryStringParams += productsPager.QueryStringProperty;
}
protected override void OnPreRender(EventArgs e)
{
this.pnlFilters.Visible = ctrlPriceRangeFilter.Visible || ctrlProductSpecificationFilter.Visible;
base.OnPreRender(e);
}
protected void dlSubCategories_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
var category = e.Item.DataItem as Category;
string categoryURL = SEOHelper.GetCategoryUrl(category);
var hlImageLink = e.Item.FindControl("hlImageLink") as HyperLink;
if (hlImageLink != null)
{
hlImageLink.ImageUrl = this.PictureService.GetPictureUrl(category.PictureId, this.SettingManager.GetSettingValueInteger("Media.Category.ThumbnailImageSize", 125), true);
hlImageLink.NavigateUrl = categoryURL;
hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Category.ImageLinkTitleFormat"), category.LocalizedName);
hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Category.ImageAlternateTextFormat"), category.LocalizedName);
}
var hlCategory = e.Item.FindControl("hlCategory") as HyperLink;
if (hlCategory != null)
{
hlCategory.NavigateUrl = categoryURL;
hlCategory.ToolTip = String.Format(GetLocaleResourceString("Media.Category.ImageLinkTitleFormat"), category.LocalizedName);
hlCategory.Text = Server.HtmlEncode(category.LocalizedName);
}
}
}
public int CurrentPageIndex
{
get
{
int _pageIndex = CommonHelper.QueryStringInt(productsPager.QueryStringProperty);
_pageIndex--;
if (_pageIndex < 0)
_pageIndex = 0;
return _pageIndex;
}
}
public int CategoryId
{
get
{
return CommonHelper.QueryStringInt("CategoryId");
}
}
}
}