Product Available Start and End Date - Show on Home Page bug?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Hi there,

I don't know the business rules behind it, but a product I have has an AvailableStartDate and AvailableEndDate that has already passed, but it remains visible on the website due to the ShowOnHomePage flag being set to 1.

Is this a bug? If so, which class returns the initial list of products so that I can alter the query? If not, what else do I need to do to get these products not to display?

Thanks,

Daniel
13 years ago
It's by design. You have to manually set ShowOnHomePage to 0 when you want to hide it
13 years ago
Thanks for the info.

If anyone else needs to change this like I did, update the GetAllProductsDisplayedOnHomePage() logic in the ProductManager to the following:

public static List<Product> GetAllProductsDisplayedOnHomePage()
        {
            bool showHidden = NopContext.Current.IsAdmin;

            int languageId = 0;
            if (NopContext.Current != null)
                languageId = NopContext.Current.WorkingLanguage.LanguageId;

            var context = ObjectContextHelper.CurrentObjectContext;
            var query = from p in context.Products
                        join pv in context.ProductVariants on p.ProductId equals pv.ProductId
                        orderby p.Name
                        where (showHidden || p.Published) &&
                        !p.Deleted &&
                        p.ShowOnHomePage &&
                        pv.AvailableStartDateTime <= DateTime.Now &&
                        pv.AvailableEndDateTime >= DateTime.Now
                        select p;
            var products = query.ToList();
            return products;
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.