How to hide products that are out of stock?
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
How to hide products that are out of stock?
How to hide products that are out of stock?
I am also interested in the possibility of first displaying those that are in stock, and then those that are out of stock
I am also interested in the possibility of first displaying those that are in stock, and then those that are out of stock
Aimeos 2024.10.3 + Laravel 11, PHP 8.2, MySql8.0, Nginx, Ubuntu 22.04.5 LTS
Re: How to hide products that are out of stock?
Stock levels are loaded async by JS due to their volatile nature:
https://github.com/aimeos/ai-client-htm ... er.php#L87
If you know at the time of the import that the product is already out of stock, you can set product.instock=0 and enable the "client/html/catalog/instock" option (set to true or 1).
To dynamically mark or hide variant articles which are out of stock, you have to adapt the JS code in catalog/stock/body.php template and remove the variant articles without stock in the catalog detail page:
https://github.com/aimeos/ai-client-htm ... k/body.php
https://github.com/aimeos/ai-client-htm ... er.php#L87
If you know at the time of the import that the product is already out of stock, you can set product.instock=0 and enable the "client/html/catalog/instock" option (set to true or 1).
To dynamically mark or hide variant articles which are out of stock, you have to adapt the JS code in catalog/stock/body.php template and remove the variant articles without stock in the catalog detail page:
https://github.com/aimeos/ai-client-htm ... k/body.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: How to hide products that are out of stock?
Thank you! That's what I needed.
As for the second point, I probably asked the question incorrectly.
My task is to have the products that are in stock at the top of the product list, and then display the ones that are not in stock after them.
As for the second point, I probably asked the question incorrectly.
My task is to have the products that are in stock at the top of the product list, and then display the ones that are not in stock after them.
Aimeos 2024.10.3 + Laravel 11, PHP 8.2, MySql8.0, Nginx, Ubuntu 22.04.5 LTS
Re: How to hide products that are out of stock?
You need to sort by product.instock and you can use that sorting by adding a macro in \App\Providers\AppServiceProvider::boot():
See here: https://github.com/aimeos/ai-client-htm ... #L420-L447
Code: Select all
\Aimeos\Client\Html\Catalog\Lists\Standard::macro('conditions', function($cntl, $view) {
$cntl->sort('-product.instock');
});
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
