Jump to content

[SOLVED] How to limit the global amount of allowed products (in the catalogue)?


Recommended Posts

Hi
I need to install latest PS for someone on my server.
But I don't like them to use a lot of server resources (free account) so I would like to limit maximum number of products they will be able to add to the shop.

Can any one point me into the right direction and help me how to set up this kind of limit in PS?
It must be some DB changing but I am not sure... Any ideas please?

Just to mention that the shop admin will have BO access only (no direct DB nor FTP access).

Link to comment
Share on other sites

Thank you for your reply but is off topic. I didn't asked how to gain resources.
And I don't see the connection between the number of products in the basket and server resources either.


This what I meant is a to limit the total (global) amount of all the product someone could add to the catalogue via BO.

I.e. I let someone to have PS shop installed onto my server for free. But don't want them to have more than 200 products in total added to the shop.
Many thanks.

Link to comment
Share on other sites

Guys.. they aren't asking how to limit the number of products in the basket when shopping. they are asking how to limit the number of products a shop owner can add to their cart. Seems like the OP is setting up a SAAS for clients using prestashop as the shopping cart software.

I dont really know enough about prestashop to tell you how to limit the number of products without messing things up though

Link to comment
Share on other sites

Its not for SAAS as you may think. But in general yes - you are right.
I want to limit the number of products a shop owner can add to their cart (catalogue).

I am giving PS installed as free but fully functional add-on to the hosting account onto my server.
But I want to limit maximum number of products shop owner can add to 200.

Any help please?

Link to comment
Share on other sites

  • 1 month later...
An "addProduct" hook is available, but... user with admin access could uninstall the controlling module, eh?
So, edit AdminProducts.php
find
public function submitAddProduct($token = NULL)
{
global $cookie, $currentIndex, $link;

and, immediately beneath those lines, insert:

$myvar = Db::getInstance()->Execute('SELECT COUNT(*) FROM '._DB_PREFIX_.'product');
if( intval($myvar) >= 2000)
{
$this->_errors[] = 'limit reached -- shop may contain 2000 products, max';
}



Save the AdminProducts.php file and test ~~ the max products limitation will take effect immediately.
(When testing, use a low number within the if statement, not 2000!)



Thanks mate this solution is perfect. Now a friend of another question, if I want to limit eg 5 images per product, as you would? Thanks
Link to comment
Share on other sites

  • 1 year later...

 

 

Thanks mate this solution is perfect. Now a friend of another question, if I want to limit eg 5 images per product, as you would? Thanks

 

Hi emmerick,

Could you tell me where is the adminproducts.php in the 1.5 Prestashop version?

I cannot find it!

Thanks!

Link to comment
Share on other sites

×
×
  • Create New...