Stock levels on front-end only take one type of stock into account
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Stock levels on front-end only take one type of stock into account
On the front-end of the site, the page makes a separate request to /default/shop/stock to retrieve the stock levels for each item in a selection product.
This data is retrieved from the data method on Aimeos\Client\Html\Catalog\Stock\Standard
However, this function only returns stock of a single type (the standard/default type by default). I see I can set a config setting per site to change which type is selected, but if I have a product with stock type "warehouse-1" > 0, it will not show as being in stock on the frontend unless "Standard" stock is also > 1.
Is there a way to have this function check all available stock types?
This data is retrieved from the data method on Aimeos\Client\Html\Catalog\Stock\Standard
However, this function only returns stock of a single type (the standard/default type by default). I see I can set a config setting per site to change which type is selected, but if I have a product with stock type "warehouse-1" > 0, it will not show as being in stock on the frontend unless "Standard" stock is also > 1.
Is there a way to have this function check all available stock types?
Re: Stock levels on front-end only take one type of stock into account
Just a quick follow-up on this, it looks like the slice() function is restricting the stock returned.
If I remove that, then all stock is found including "warehouse-1"
Would there be any harm in overriding this class/method to remove the slice?
If I remove that, then all stock is found including "warehouse-1"
Code: Select all
$sort = $context->config()->get( 'client/html/catalog/stock/sort', 'stock.type' );
$type = $context->locale()->getSiteItem()->getConfigValue( 'stocktype' );
$view->stockProductIds = $prodIds;
$view->stockItemsByProducts = \Aimeos\Controller\Frontend::create( $context, 'stock' )
->product( $prodIds )->type( $type )->sort( $sort )
/*->slice( 0, count( $prodIds ) )*/
->search()
->groupBy( 'stock.productid' );
return parent::data( $view, $tags, $expire );
Re: Stock levels on front-end only take one type of stock into account
If you create a pull request, we are happy to merge the fix
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Stock levels on front-end only take one type of stock into account
Sure, no problem. I have just submitted a pull request now
Re: Stock levels on front-end only take one type of stock into account
Thanks! Now it's merged and also available in 2022.10.x-dev until a new version is tagged.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star