Featured Product

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
rohitsrivastava
Ensign (ENS)
Ensign (ENS)
Posts: 17
Joined: Thu Dec 18, 2008 8:28 am

Featured Product

Post by rohitsrivastava » Mon Feb 09, 2009 8:34 am

Hi,

Please help me to resolve this problem ...
i am using
" ProductList.DataSource = ProductList.DataSource = ProductDataSource.GetRandomFeaturedProducts(int.Parse(Request.QueryString["cID"].ToString()), true, this.Size);"
and
int categoryId = PageHelper.GetCategoryId();
ProductList.DataSource = ProductDataSource.GetFeaturedProducts(categoryId, true,8);

"GetRandomFeaturedProducts" and "GetFeaturedProducts" both are using for displaying the featured products list , but in this methodology we have to check the "FEATURED" option ,it is not a correct way to display product (Catelog) but on the other hand if i want to display product without checking "FEATURED" option (in admin module)so what we should do...

in this functionality if we are not checking "Featured" option so that products are not displaiyng in catalog list these products are invisible ...

so what we can use instead of featured product for displaying the product in front end.....

Regards
Rohit Srivastava

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

Re: Featured Product

Post by mazhar » Mon Feb 09, 2009 8:37 am

If you want to show products from some category you can do this as below

Code: Select all

        CommerceBuilder.Catalog.CatalogNodeCollection nodes = CommerceBuilder.Catalog.CatalogDataSource.LoadForCategory(categoryId,true);
        ProductCollection products = new ProductCollection();
        foreach(CommerceBuilder.Catalog.CatalogNode node in nodes)
        {
            if(node.CatalogNodeType == CommerceBuilder.Catalog.CatalogNodeType.Product)
                products.Add((Product)node.ChildObject);
        }
        ProductList.DataSource = products;

rohitsrivastava
Ensign (ENS)
Ensign (ENS)
Posts: 17
Joined: Thu Dec 18, 2008 8:28 am

Re: Featured Product

Post by rohitsrivastava » Tue Feb 10, 2009 1:18 am

Hi,

Thanks a lot for your help , but please guide me where i have to place this code ?
and can all the products will display without click (check) "Featured" option ?
i have place this code to page load on "FeaturedProductGrid.ascx" and commented previos one...
but it is not working , there is no products are displying whether it is Featured or non Featured

Thanks And regards
Atul khare

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

Re: Featured Product

Post by mazhar » Tue Feb 10, 2009 4:31 am

Yes this code will list the products belonging to any category you specified in categoryId, it will not care that featured products check box is checked or not. For example if you have a category named "Test Cat" and wants show all its products in featured products grid control then first you have a take a look at the ac_Categories table to find out the CategoryId of this category, suppose the category id for "Test Cat" was 5. Then edit the featrued products grid and locate the following line of code in it.

Code: Select all

ProductList.DataSource = ProductDataSource.GetRandomFeaturedProducts(0, true, this.Size);
and change it as below

Code: Select all

CommerceBuilder.Catalog.CatalogNodeCollection nodes = CommerceBuilder.Catalog.CatalogDataSource.LoadForCategory(5,true);
        ProductCollection products = new ProductCollection();
        foreach(CommerceBuilder.Catalog.CatalogNode node in nodes)
        {
            if(node.CatalogNodeType == CommerceBuilder.Catalog.CatalogNodeType.Product)
                products.Add((Product)node.ChildObject);
        }
        ProductList.DataSource = products;
        ProductList.DataBind();
Where LoadForCategory(5,true) means load all items of "Test Cat"

Post Reply