Page 1 of 1

Add to Cart on CategoryDetailsPage

Posted: Fri Oct 23, 2009 10:48 am
by jsmits
I am trying to add an AddToCartLink to the CategoryDetailsPage by doing something like this:

Code: Select all

<asp:PlaceHolder ID="phCategoryContents" runat="server">            
            <!-- Top Bar -->
            <div class="catalogWrapper" style="padding:0px;">
                <asp:Repeater ID="CatalogNodeList" runat="server" OnItemDataBound="CatalogNodeList_ItemDataBound" EnableViewState="false">
                    <HeaderTemplate>
                        <table width="100%">
                    </HeaderTemplate>
                    <ItemTemplate>                       
                        <asp:PlaceHolder ID="phItemTemplate1" runat="server"></asp:PlaceHolder>  
                        <uc:AddToCartLink ID="Add2Cart" runat="server" ProductId='<%#Eval("ProductId")%>' />
                    </ItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                    <SeparatorTemplate>
                        <tr><td colspan="2"><hr /></td></tr>
                    </SeparatorTemplate>
                </asp:Repeater>                
            </div>            
        </asp:PlaceHolder>
But the catalogNode object doesn't have the property ProductId, so the above won't work. Is there a better way to do this?

Re: Add to Cart on CategoryDetailsPage

Posted: Fri Oct 23, 2009 1:12 pm
by jmestep
You can try the CatalogNodeId instead of ProductId. If that doesn't work, then you would need to load the product for that CatalogNodeId.
Product product = new Product();
product = ProductDataSource.Load(CatalogNodeId);
(Off the top of my head)

Re: Add to Cart on CategoryDetailsPage

Posted: Mon Oct 26, 2009 10:06 am
by jsmits
Thanks Judy, CatalogNodeId worked like a charm.