Jump to content

category->getProducts() select only in-stock products in 1.6.x


brainstormtrooper

Recommended Posts

Hi,

I'm trying to get the Category class to return only products with a quantity greater than 0 in PS 1.6

 

I tried 

http://www.prestashop.com/forums/topic/256812-modify-getproducts/?hl=select+product+with+quantity

but it didn't seem to change anything.

 

I don't want them disabled, just not presented...

I have them hidden in the template, but then pagination is messed up. 

 

Thanks in advance for any help or advice,

 

 

Link to comment
Share on other sites

  • 8 months later...

I suggest overriding the Category::getProducts() function. Copy the entire function into the override and then change both WHERE to:

WHERE p.`quantity` > 0 AND

I haven't tested this, but it should make all products without stock invisible. It might make them invisible in the Back Office too though. If that happens, you'll have to use more complicated code like:

WHERE '.(substr(Tools::getValue('controller'), 0, 5) != 'Admin' ? 'p.`quantity` > 0 AND ' : '').'

Good luck

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...