Try These Categories Fix

Posted By jcosmo Fri 15 Jan 2016
Add to Favorites0
Author Message
jcosmo
 Posted Fri 15 Jan 2016
Supreme Being

Supreme Being - (10,475 reputation)Supreme Being - (10,475 reputation)Supreme Being - (10,475 reputation)Supreme Being - (10,475 reputation)Supreme Being - (10,475 reputation)Supreme Being - (10,475 reputation)Supreme Being - (10,475 reputation)Supreme Being - (10,475 reputation)Supreme Being - (10,475 reputation)

Group: Forum Members
Last Active: Tue 16 Feb 2016
Posts: 19, Visits: 117
I tried to turn off Try These Categories by setting frontend.crossselling.trythesecategories to 0. It didn't work, and when I traced through the code to see why I found that the Try These Categories functionality wasn't using this parameter at all for determining how many categories to show. I corrected this through the following changes:

Updated the Stored Procedure to accept and use the number of Categories to display with the following SQL Statement:
ALTER PROCEDURE [dbo].[spKartrisCategories_GetByProductID]
(
@P_ID int,
@LANG_ID tinyint,
@numTryTheseCategories int
)
AS
SET NOCOUNT ON;
SELECT TOP (@numTryTheseCategories) vKartrisTypeCategories.CAT_ID, vKartrisTypeCategories.CAT_Name
FROM vKartrisTypeCategories INNER JOIN
tblKartrisProductCategoryLink ON vKartrisTypeCategories.CAT_ID = tblKartrisProductCategoryLink.PCAT_CategoryID
WHERE (vKartrisTypeCategories.LANG_ID = @LANG_ID) AND (tblKartrisProductCategoryLink.PCAT_ProductID = @P_ID)
GO


Updated the katrisCategoriesData.xsd data adapter to include the new parameter

Updated the CategoriesBLL.vb at line 59 to be:
Public Shared Function GetCategoriesByProductID(ByVal _ProductID As Integer, ByVal _LanguageID As Short, ByVal _numTryTheseCategories As Integer) As DataTable
Return Adptr.GetByProductID(_ProductID, _LanguageID, _numTryTheseCategories)
End Function


Updated the CarryOnShopping.ascx.vb at line 120 to be:
Sub LoadLinkedCategories()


Dim intTryTheseCategories As Integer


Try
intTryTheseCategories = CInt(GetKartConfig("frontend.crossselling.trythesecategories"))
Catch ex As Exception
intTryTheseCategories = 0
End Try


If intTryTheseCategories > 0 Then
'' Add the linked categories to a DataTable
Dim tblCategories As New DataTable
tblCategories = CategoriesBLL.GetCategoriesByProductID(_ProductID, _LanguageID, intTryTheseCategories)


'' If there is no linked categories, then exit this section.
If tblCategories.Rows.Count = 0 Then Exit Sub


'' Bind the linked categories in to rptLinkedCategories, and View its container.
phdLinkedCategories.Visible = True
rptLinkedCategories.DataSource = tblCategories.DefaultView
rptLinkedCategories.DataBind()
Else
''Hide try these categories section
phdLinkedCategories.Visible = False
End If
End Sub


This appears to be a bug fix and not new functionality, so it would be great to see these changes implemented in the next release.
Paul
 Posted Fri 5 Feb 2016
große Käse

große Käse - (508,970 reputation)große Käse - (508,970 reputation)große Käse - (508,970 reputation)große Käse - (508,970 reputation)große Käse - (508,970 reputation)große Käse - (508,970 reputation)große Käse - (508,970 reputation)große Käse - (508,970 reputation)große Käse - (508,970 reputation)

Group: Administrators
Last Active: Tue 10 Sep 2024
Posts: 807, Visits: 2,748
I've approached this slightly simpler way. I've kept the sproc unchanged; at present it pulls out all categories, but in most cases products aren't going to be in more than a handful of categories, so there isn't really a performance issue returning more than we might actually need.

I've just modified the LoadLinkedCategories() sub:


Dim intLinkedCategories As Integer

Try
intLinkedCategories = CInt(GetKartConfig("frontend.crossselling.trythesecategories"))
Catch ex As Exception
intLinkedCategories = 0
End Try

If intLinkedCategories > 0 Then
'' Add the linked categories to a DataTable
Dim tblCategories As DataTable = CategoriesBLL.GetCategoriesByProductID(_ProductID, _LanguageID).Rows.Cast(Of System.Data.DataRow)().Take(intLinkedCategories).CopyToDataTable()
'dt.Rows.Cast<System.Data.DataRow>().Take(n)

'' If there is no linked categories, then exit this section.
If tblCategories.Rows.Count = 0 Then Exit Sub

'' Bind the linked categories in to rptLinkedCategories, and View its container.
phdLinkedCategories.Visible = True
rptLinkedCategories.DataSource = tblCategories.DefaultView
rptLinkedCategories.DataBind()
Else
phdLinkedCategories.Visible = False
End If


This hides the control if the value is zero to display. But if it is a number above that, we just apply a 'Take' to the datatable for the number of records we want. It's just a simple way of limiting the number we display without having to modify the sproc and DAL.


--
If my post solves your issue, can you 'Mark as Answer' so it's easier for other users to find in future.

If you would like to be informed of new features, new releases, developments and occasional special bonuses, please sign up to our mailing list: http://bit.ly/19sKMZb
Fri 5 Feb 2016 by Paul

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top