• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

drodriguez
#1 Posted : Wednesday, July 9, 2008 3:22:20 PM(UTC)
drodriguez

Rank: Member

Joined: 6/26/2008(UTC)
Posts: 38

[3]EXECUTIVE SUMMARY [/3]
I need a featured product to be listed on top of a category page that lists a Grid View (in one case) and a Detail View (in another).

[3]3RD PARTY ADD ON? [/3]
Is there a third party add-on that will handle this?

[3]THE KLUDGE WAY [/3]
I know of one way to do this, but it's ugly:

Create a category for each featured product and then put that on a New Column and then use that New Column. That's a lot of replication, because there are a lot of categories.

[3]INTERNAL TRACKING [/3]
What really should be done is for a new ASCX control to pull up the calling category's list of products and, somehow, differentiate among them and figure out which is the "super special, featured" product. Are there columns for this in the database? Looking at the tables I admit to being ignorant of even how a product is tied to a category - I know there is a table or two linking them but I didn't spot it.


As always ladies and gentlemen, my thanks in advance for your time.
David Rodriguez
Infinet Development, Inc.
General_Tools
#2 Posted : Monday, July 14, 2008 9:12:18 AM(UTC)
General_Tools

Rank: Member

Joined: 1/10/2008(UTC)
Posts: 10

I was working on a similar solution and found a few things pre-built into the category template.

<asp:HyperLink runat="server" ID="featuredImage" BorderColor="black" BorderWidth="1px" />
<asp:Label ID="lblFeaturedName" runat="server"></asp:Label>
<asp:Label ID="lblFeaturedSku" runat="server"></asp:Label>
<asp:Literal ID="FeaturedDescriptionLiteral" runat="server"></asp:Literal>

then in the VB file, i found this code which i modified slightly:

Public Sub LoadFeatured(ByVal p As Catalog.Product)

' Name Fields
Me.lblFeaturedName.Text = p.ProductName
Me.lblFeaturedSku.Text = p.Sku
' Check if size of text is within 200 chars limit
If p.LongDescription.Length > 200 Then
Me.FeaturedDescriptionLiteral.Text = Left(p.LongDescription, 189 ) & " (more...)"
Else
Me.FeaturedDescriptionLiteral.Text = p.LongDescription
End If

' Image
Me.featuredImage.ImageUrl = Page.ResolveUrl(Utilities.ImageHelper.GetValidImage(p.ImageFileSmall, True))
Me.featuredImage.NavigateUrl = Utilities.UrlRewriter.BuildUrlForProduct(p, Me.Page.Request)

End Sub

This would be similar to what you consider the "detail view". it shows the product image, title, SKU and a 200 character description. i tested it over the weekend and it works except for the featured product never changes. i have no idea how it is deciding what product to put up there. does anyone know how/where the featured product is chosen?
eric
#3 Posted : Monday, July 14, 2008 10:54:48 AM(UTC)
eric

Rank: Member

Joined: 4/25/2003(UTC)
Posts: 71

The featured product is loaded in the Sub 'PopulateCategoryInfo'. It loads the first product based on the category sort order.
General_Tools
#4 Posted : Monday, July 14, 2008 4:20:38 PM(UTC)
General_Tools

Rank: Member

Joined: 1/10/2008(UTC)
Posts: 10

got it, so then to randomize what product appears i could just change the # listed with LoadFeatured(children(#)). depending on the # of products you have:

Dim children As Collection(Of Catalog.Product) = LocalCategory.FindAllProducts(WebAppSettings.DisableInventory, False)
Dim i As Integer
Randomize
i = Int(Rnd() * 10) + 1
If children.Count > 0 Then
LoadFeatured(children(i))
End If
eric
#5 Posted : Tuesday, July 15, 2008 7:47:33 AM(UTC)
eric

Rank: Member

Joined: 4/25/2003(UTC)
Posts: 71

Sounds good... if you don't want to code your own random number, there are a couple of 'randomizers' supplied by BV in
Core.Utilities.RandomNumbers.



Haven't tested this, but it should work...



Dim children As Collection(Of Catalog.Product) = LocalCategory.FindAllProducts(WebAppSettings.DisableInventory, False)
Dim i as integer = 0

If children.count &gt; 0 then

i = [2]Utilities.RandomNumbers.RandomInteger(children.Count, 0)[/2]

LoadFeatured(children(i))

End if
General_Tools
#6 Posted : Tuesday, July 15, 2008 9:39:11 AM(UTC)
General_Tools

Rank: Member

Joined: 1/10/2008(UTC)
Posts: 10

thanks eric, that randomizer works much better than what i was using. the only issue i had was that it occasionally kicked back an "index out of range" error, presumably because the random number (i) was greater than the number of products in the category. this adjustment seemed to work for me:

Dim children As Collection(Of Catalog.Product) = LocalCategory.FindAllProducts(WebAppSettings.DisableInventory, False)
Dim i As Integer
i = Utilities.RandomNumbers.RandomInteger(children.Count, 0)
If children.count &gt; 0 and children.count &gt; i
LoadFeatured(children(i))
Else
LoadFeatured(children(0))
End If

I hope this helps someone else down the line. Thanks again Eric.
eric
#7 Posted : Tuesday, July 15, 2008 4:50:27 PM(UTC)
eric

Rank: Member

Joined: 4/25/2003(UTC)
Posts: 71

I'm glad I could help!


Whoops...The child collection is 0 based... so you need to subtract 1 from the randominteger. See the modified code below:

Dim children As Collection(Of Catalog.Product) = LocalCategory.FindAllProducts(WebAppSettings.DisableInventory, False)
Dim i as integer = 0
If children.count &gt; 0 then
i = Utilities.RandomNumbers.RandomInteger(children.Count, 0)
LoadFeatured(children(i-1)) &lt;--- changed this line
End if
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2024 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012