Jump to content

Empty stock product still appears on the website


Recommended Posts

i'm using PS 1.4.4.1

I'm still testing it and i've got a problem when the last product in stock is bought (quantity = 0) : then product still appears in the category and in the search field (ajax search).

 

Why ??

Considering i've checked the options :

- Enable stock management => YES

- Allow ordering of out-of-stock products => NO

is it me or should this product be hidden ?

 

Have i missed a checkbox somewhere in the back office ? Should i override some classes ?

 

If anyone has a clue, i'll be glad to hear it.

Thanks

Link to comment
Share on other sites

Hmm, i understand it with the option "Allow ordering of out-of-stock products" but if not checked i think

- it's frustrating for a client to see the product he will maybe never get if it's not refilled

- it's inconvenient for the admin to deactivate every empty stock product one by one

 

I think i'll overide the classes then :

For PS 1.4.4.1

 

to add p.quantity > 0

Search.php

around line 240

   	 if ($ajax)
	{
		return $db->ExecuteS('
		SELECT DISTINCT p.id_product, pl.name pname, cl.name cname,
			cl.link_rewrite crewrite, pl.link_rewrite prewrite '.$score.'
		FROM '._DB_PREFIX_.'product p
		INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.')
		INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.')
		WHERE p.`id_product` '.$productPool.' AND p.quantity > 0
		ORDER BY position DESC LIMIT 10');
	}

 

and

Category.php

in the sql query around line 43, and in the one around line 52,and in the one around line 133, and in the one around line 142

...
WHERE p.quantity > 0 and cp.`id_category` = '.(int)($this->id).($active ? ' AND p.`active` = 1' : '').'

 

I got my empty products not returned...

I have to check though it doesn't break other stuff

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...