Jump to content

different stock quantities


Recommended Posts

Hi all!

 

I just wondering how is my shop show a different quantity on a product page, that in the

 

ps_product table / quantity column?!

 

 

 

As I investigate, the showed qty is in ps_stock_available table, but I do not understand why??

 

Could someone explain me how to show the qty from the originlal ps_product table?

 

I do not use multistore or advanced stock management function!

 

 

Link to comment
Share on other sites

ps_stock_available is not an option. You have to consider the quantity column on ps_product to be an historical artefact of no use.

Not a single piece of Prestashop core updates it, and not a single module should update or rely on it.

 

If you need to knwo the quantity available in a single query:

select p.id_product, coalesce(pa.id_product_attribute,0) as id_product_attribute,
if (pa.reference = '',p.reference, coalese(pa.reference,p.reference) as reference,
sa.quantity,
<other field you may find usefull>
from ps_product p
left join ps_product_attribute pa on p.id_product = pa.id_product
inner join ps_stock_available sa  on (
  sa.id_product = p.id_product 
  and sa.id_product_attribute = coalesce(pa.id_product_attribute,0)
  and sa.id_shop = 1
)
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...