How to show a list of product assets for a category

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
pjchan_2000
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Sat Aug 21, 2010 8:38 pm

How to show a list of product assets for a category

Post by pjchan_2000 » Sat Aug 21, 2010 9:13 pm

Hi, I'm new to AbleCommerce, so pls excuse if this question has been asked or if the answer is obvoius
I've got a product category in which each and every product should have a link to a product-specific readme page (pdf).
1st question: is there an existing control that would let me resolve the url of each readme file at display time rather than having to create each by hand? the readme has the product code (SKU) in its file name.

Assuming that I resolve the requirement above or I create the links for each product by hand, then...

2nd Question: I know (I think) how to use a side bar to display a product's assets (including the link to the readme_xxx.pdf file for that product), but is there a way in which I can display the links to the readme_xxx.pdf files of ALL products under a given category in one page? Without having to create all the links by hand for that category, that is.

That's it for now. Thanks in advance for your suggestions.
Pedro

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: How to show a list of product assets for a category

Post by mazhar » Mon Aug 23, 2010 1:15 am

1st question: is there an existing control that would let me resolve the url of each readme file at display time rather than having to create each by hand? the readme has the product code (SKU) in its file name.

Assuming that I resolve the requirement above or I create the links for each product by hand, then...
Well you can create your custom control to do this job. Create a user control in Website/ConLib folder. You can put some code to generate a URL to PDF file on some web accessible folder using SKU of the product. Then you can simply place that control on your product details page.
2nd Question: I know (I think) how to use a side bar to display a product's assets (including the link to the readme_xxx.pdf file for that product), but is there a way in which I can display the links to the readme_xxx.pdf files of ALL products under a given category in one page? Without having to create all the links by hand for that category, that is.
You can try to sum up with some code do this job for you and automatically create the links. It could be something like

Code: Select all

int parentCategoryId = 3;
        string readmeFilesPath = Server.MapPath("~/ReadMe"); //FOLDER CONTAINING PDF FILES ON ROOT
        string[] filePaths = System.IO.Directory.GetFiles(readmeFilesPath);
        if (filePaths != null)
        {
            foreach (string filePath in filePaths)
            {
                System.IO.FileInfo readmeInfo = new System.IO.FileInfo(filePath);
                CommerceBuilder.Catalog.Link link = new CommerceBuilder.Catalog.Link();
                link.Name = readmeInfo.Name;
                string navigateUrl = CommerceBuilder.Common.Token.Instance.Store.StoreUrl;
                if (!navigateUrl.EndsWith("/"))
                    navigateUrl = navigateUrl + "/";
                navigateUrl += readmeInfo.Name;
                link.NavigateUrl = navigateUrl;
                link.StoreId = CommerceBuilder.Common.Token.Instance.Store.StoreId;
                link.Categories.Add(parentCategoryId);
                link.Save();
            }
        }

pjchan_2000
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Sat Aug 21, 2010 8:38 pm

Re: How to show a list of product assets for a category

Post by pjchan_2000 » Mon Aug 23, 2010 4:32 pm

Thanks Mazhar, in the end I did something like what you suggested, a control to generate a link based on the SKU, and then I created a page that walks through all products of a category (based on the Category Grid) and uses the control to show all links related to products of that category. It's working quite nicely.
Thanks a lot for your response

Pedro

Post Reply