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,

Re: How to hide products that are out of stock?
I added your piece of code. But unfortunately, nothing changed.


Code: Select all
<?php
namespace App\Providers;
use Illuminate\Validation\Rules\Password;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Password::defaults(function () {
$rule = Password::min( 8 );
return $this->app->isProduction() ? $rule->mixedCase()->uncompromised() : $rule;
});
// for multi-locale/site setups
\Illuminate\Auth\Notifications\ResetPassword::createUrlUsing(function($notifiable, $token) {
return url(airoute('password.reset', [
'email' => $notifiable->getEmailForPasswordReset(),
'token' => $token,
], false));
});
// for multi-locale/site setups
\Illuminate\Auth\Notifications\VerifyEmail::$createUrlCallback = function($notifiable) {
$time = Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60));
$params = [
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
];
if( config( 'app.shop_multilocale' ) ) {
$params['locale'] = Request::route( 'locale', Request::input( 'locale', app()->getLocale() ) );
}
if( config( 'app.shop_multishop' ) || config( 'app.shop_registration' ) ) {
$params['site'] = Request::route( 'site', Request::input( 'site', config( 'shop.mshop.locale.site', 'default' ) ) );
}
return URL::temporarySignedRoute('verification.verify', $time, $params);
};
// Aimeos admin check for backend
\Illuminate\Support\Facades\Gate::define('admin', function($user, $class, $roles) {
if( isset( $user->superuser ) && $user->superuser ) {
return true;
}
return app( '\Aimeos\Shop\Base\Support' )->checkUserGroup( $user, $roles );
});
// Aimeos context for icon and logo in all Blade templates
View::composer('*', function ( $view ) {
try {
$view->with( 'aimeossite', app( 'aimeos.context' )->get()->locale()->getSiteItem() );
} catch( \Exception $e ) {
$view->with( 'aimeossite', \Aimeos\MShop::create( app( 'aimeos.context' )->get( false ), 'locale/site' )->create() );
}
});
// resolve CMS pages sharing same route as categories and products
\Aimeos\Shop\Controller\ResolveController::register( 'cms', function( $context, $path ) {
return $this->cms( $context, $path );
});
Schema::defaultStringLength(191);
\Aimeos\Client\Html\Catalog\Lists\Standard::macro('conditions', function($cntl, $view) {
$cntl->sort('-product.instock');
});
}
}
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?
Is the product.instock property set correctly when you import products?
It's not updated automatically at the moment because it would be costly to update it for each ordered product when the stock level changes.
It's not updated automatically at the moment because it would be costly to update it for each ordered product when the stock level changes.
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?
No, we did not import. We manually added products.
Out of stock:

In stock:

Did I set it up correctly?
Out of stock:

In stock:

Did I set it up correctly?
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?
Unfortunately, this is the only product property that can be only set in a product import because it's meant for ERP systems informing Aimeos about products that are not available any more.
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?
So it turns out that there is absolutely no way to filter by availability in 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?
Like said, you can sort/filter by stock when using product.instock property if you import products by CSV or XML.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
