Hello,
I'm trying to get the products in the front end sorted by in stock but I get out of stock products mixed in mostly towards the end of the list.
by availability is mixed up even more.
I could use bty sorting and just do it manually but that's time consuming the stock changes frequently on too many products.
anybody else experienced this? thank you
You can set in VM>Configuration> Product Order Settings :
Default product sort order : Product in stock
Available Sort-by fields : Product in stock
This is then ordered by stock, but this not count pending product in order.
Quote from: Studio 42 on March 08, 2016, 01:22:45 AM
You can set in VM>Configuration> Product Order Settings :
Default product sort order : Product in stock
Available Sort-by fields : Product in stock
This is then ordered by stock, but this not count pending product in order.
Hello I wrote above that I did this already but it doesn't work. still I see out of stock products mixed in with the in stock items.
Action when a Product is Out of Stock -> Do not Display Product ????
Quote from: GJC Web Design on March 10, 2016, 00:26:42 AM
Action when a Product is Out of Stock -> Do not Display Product ????
thank you but unfortunately they want the out of stock products to show on the site with the ability to have a notify list. you know which site i'm talking about you can see what i mean ...
hmmm.. where do u want the out of stock to appear? at the bottom?
I can only assume the query is using say a stock of -3, -4 etc as a positive integer?
have a look in the model products.php the query for stock to test this theory
Quote from: GJC Web Design on March 10, 2016, 11:35:43 AM
hmmm.. where do u want the out of stock to appear? at the bottom?
I can only assume the query is using say a stock of -3, -4 etc as a positive integer?
have a look in the model products.php the query for stock to test this theory
They want out of stock products to appear at the end of the list after the in-stock products. from what I understand sort by 'availability' should be the correct choice for that so it reflects booked orders as well but that doesn't work for me either. totaly out of stock product with 0 stcok get mixed in still. it does happen after the first few rows but i dont think there is a certain patern i could point to
will look into model products.php to try different things thank you
yes.. but stock can also be -1, -2 etc
or are they all definitely 0?
yes they are all definitely zero. no back orders. just notify list. and very high stock change rate
then to solve this u need to dig into the actual queries of models product.php
add a vmDebug or any var_dump and check the current query and result, when you use order by stock, so you see why the result is bad.
We tried doing the same but never managed to order them automatically in the desired way.
If you use child products only the parent is counted for ordering so we ended up doing it manually.
Hello all,
I have exact the same problem in multiple sites. I want to sort the products based on availability but it is not working. I have tried lots of things, even disable the template but the problem still happens. For example you can see site ddc.gr. Is there anyone who can help? Does anyone face the same problem?
Does anyone have the same issue?
I think you can make a custom sort function and sort using usort. It's not the most ideal situation, because ideally you want to do this with the query, but with usort you can sort he products in your template override.
Quote from: Kuubs on August 22, 2022, 10:22:53 AM
I think you can make a custom sort function and sort using usort. It's not the most ideal situation, because ideally you want to do this with the query, but with usort you can sort he products in your template override.
Do you know which core file I have to change in order to achieve this?
Quote from: el02154 on September 02, 2022, 09:41:29 AM
Quote from: Kuubs on August 22, 2022, 10:22:53 AM
I think you can make a custom sort function and sort using usort. It's not the most ideal situation, because ideally you want to do this with the query, but with usort you can sort he products in your template override.
Do you know which core file I have to change in order to achieve this?
you can make a template override, for example the category page. and you cahgne the products.php sublayout to sort your array of products before you render them
I can only assume the query is using say a stock of -3, -4 etc as a positive integer?
Quote from: Kuubs on September 09, 2022, 15:44:33 PM
Quote from: el02154 on September 02, 2022, 09:41:29 AM
Quote from: Kuubs on August 22, 2022, 10:22:53 AM
I think you can make a custom sort function and sort using usort. It's not the most ideal situation, because ideally you want to do this with the query, but with usort you can sort he products in your template override.
Do you know which core file I have to change in order to achieve this?
you can make a template override, for example the category page. and you cahgne the products.php sublayout to sort your array of products before you render them
Hello, this is what I am trying to do but I am struggling to grab all producys before pagination. Any ideas how to grab all products and not only the ones of the current pagination page?
If you want to add your own search, then you can use 2 triggers. So a plugin is the right way to go, it is mainly a "hello world" plugin with one trigger.
so very simple to write. overtake the query completly with plgVmMySortSearchListProductsQuery or modify the existing query with plgVmBeforeProductSearch
But I think your code is interesting for the general core. Search for the line if(VmConfig::get('stockhandle_products',false)){ or in general for stockhandle_products in the product model.
Maybe you find a fix for the problem, than we can just add it to the core. Maybe just as new option of stockhandle_products