@@ -26,10 +26,11 @@ public override void Add(ProductListWidget item)
2626 }
2727 public override WidgetPart Display ( WidgetBase widget , ControllerContext controllerContext )
2828 {
29- ProductListWidget pwidget = widget as ProductListWidget ;
29+ ProductListWidget currentWidget = widget as ProductListWidget ;
3030 var filter = new DataFilter ( ) ;
3131 filter . Where ( "IsPublish" , OperatorType . Equal , true ) ;
3232 filter . OrderBy ( "CreateDate" , OrderType . Descending ) ;
33+ var categoryService = ServiceLocator . Current . GetInstance < IProductCategoryService > ( ) ;
3334
3435 int pageIndex = controllerContext . RouteData . GetPage ( ) ;
3536 int category = controllerContext . RouteData . GetCategory ( ) ;
@@ -40,37 +41,44 @@ public override WidgetPart Display(WidgetBase widget, ControllerContext controll
4041 }
4142 else
4243 {
43- var categoryService = ServiceLocator . Current . GetInstance < IProductCategoryService > ( ) ;
44- var ids = categoryService . Get ( new DataFilter ( ) . Where ( "ParentID" , OperatorType . Equal , pwidget . ProductCategoryID ) ) . Select ( m => m . ID ) ;
44+ var ids = categoryService . Get ( new DataFilter ( ) . Where ( "ParentID" , OperatorType . Equal , currentWidget . ProductCategoryID ) ) . Select ( m => m . ID ) ;
4545 if ( ids . Any ( ) )
4646 {
47- filter . Where ( "ProductCategoryID" , OperatorType . In , ids . Concat ( new [ ] { pwidget . ProductCategoryID } ) ) ;
47+ filter . Where ( "ProductCategoryID" , OperatorType . In , ids . Concat ( new [ ] { currentWidget . ProductCategoryID } ) ) ;
4848 }
4949 else
5050 {
51- filter . Where ( "ProductCategoryID" , OperatorType . Equal , pwidget . ProductCategoryID ) ;
51+ filter . Where ( "ProductCategoryID" , OperatorType . Equal , currentWidget . ProductCategoryID ) ;
5252 }
5353 }
5454
5555
5656 var service = ServiceLocator . Current . GetInstance < IProductService > ( ) ;
5757 IEnumerable < ProductEntity > products = null ;
58- var page = new Pagination { PageIndex = pageIndex , PageSize = pwidget . PageSize ?? 20 } ;
59- if ( pwidget . IsPageable )
58+ var pagin = new Pagination { PageIndex = pageIndex , PageSize = currentWidget . PageSize ?? 20 } ;
59+ if ( currentWidget . IsPageable )
6060 {
61- products = service . Get ( filter , page ) ;
61+ products = service . Get ( filter , pagin ) ;
6262 }
6363 else
6464 {
6565 products = service . Get ( filter ) ;
6666 }
67+
68+ var categoryEntity = categoryService . Get ( category == 0 ? currentWidget . ProductCategoryID : category ) ;
69+ if ( categoryEntity != null )
70+ {
71+ var page = controllerContext . HttpContext . GetLayout ( ) . Page ;
72+ page . Title = ( page . Title ?? "" ) + " - " + categoryEntity . Title ;
73+ }
74+
6775 return widget . ToWidgetPart ( new ProductListWidgetViewModel
6876 {
6977 Products = products ,
70- Page = page ,
71- IsPageable = pwidget . IsPageable ,
72- Columns = pwidget . Columns ,
73- DetailPageUrl = pwidget . DetailPageUrl
78+ Page = pagin ,
79+ IsPageable = currentWidget . IsPageable ,
80+ Columns = currentWidget . Columns ,
81+ DetailPageUrl = currentWidget . DetailPageUrl
7482 } ) ;
7583 }
7684 }
0 commit comments