Limit products added to site

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

I am currently using nop 2.30 and was hoping some one would know the answer to this, I want to limit the amount of products that my client can add to his site, the reason is because he wants to add as many products as he can and my fear is that he's site will slow the server down causing problems for everyone else on there, I want to limit his products to 1000 and no more, if someone can help me with this I would really appriciate it.

Regards
Ron
12 years ago
There is no such capability built in.  You could customize the code to deal with it, but I think the easiest way might be putting a trigger on the Product or ProductVariant table - raise exception when Id >= 1000
12 years ago
New York wrote:
There is no such capability built in.  You could customize the code to deal with it, but I think the easiest way might be putting a trigger on the Product or ProductVariant table - raise exception when Id >= 1000

I wouldn't do it because products can be deleted but identifiers will be reserved. I would better add a validation in 'InsertProduct' method of 'ProductService' class.
12 years ago
Hi Andrei

Many thanks for you're help, would  I be able to get a record count from here ? and I know this is a bit cheeky
but I am new to MVC3, I dont suppose you would have a small peice of sample code I could work from !! :O))

Kind Regards
Ron
12 years ago
Something like
int totalProducts = SearchProducts(0, 0, null, null, null, 0, string.Empty, false, 0, null, ProductSortingEnum.Position, 0, 1).TotalCount;
12 years ago
Hi Andrei

Many thanks, most appriciated.

Kind Regards
Ron
12 years ago
Hi Andrei

The code you kindly helped with to return a product count will not work in 2.50 has anything changed the would effect the outcome, the error I get is "No overload for method 'SearchProducts' takes 13 arguments.

int totalProducts = _productService.SearchProducts(0, 0, null, null, null, 0, string.Empty, false, 0, null, ProductSortingEnum.Position, 0, 1).TotalCount;

I have tried diffrent ways but to no avail, any ideas?.

Kind Regards
Ron
12 years ago
Hi Andrei

I think i have solved the issue, would you be kind enough to just check it for me, as I want to make sure I have done this correctly.

            IList<int> filterableSpecificationAttributeOptionIds = null;
            int totalProducts = _productService.SearchProducts(0, 0, false, null, null, 0, String.Empty, false, 0, null,ProductSortingEnum.Position, 0, 1, false, out filterableSpecificationAttributeOptionIds, false).TotalCount;

Kind Regards
Ron
12 years ago
Yes, everything is correct
12 years ago
Thank you Andrei

Thats most appriciated.

Kind regards
Ron
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.