Page 1 of 2

How to hide unique products in catalogue when they are sold?

Posted: 14 Sep 2017, 08:02
by hasmb
Hi,

in a shop selling unique products (works of art) we want to hide them from customers in the catalogue when they are sold.

Is there a possibility to only show products with stocklevel > 0?

Or how can the product be set deactivated or archived when last item is sold/delivered?

Thanks.

BTW: customer likes the new easy/simple mode.

Re: How to hide unique products in catalogue when they are s

Posted: 14 Sep 2017, 17:05
by aimeos
The stock level data is loaded async via AJAX.

You have three options:
- Extend the Javascript method that's used to add the stock levels to hide those products
- Extend the catalog lists class where you retrieve the stock levels for the products and remove those that are out of stock
- Write a frontend controller decorator that deactivates the product if it's out of stock

The Javascript approach is very simple to implement. The first two options have the disadvantage that a product listing can contain less products than normal, e.g. 23 products instead of 24 on the first page, 24 on the second and so on. Which do you prefer?

That's good to hear that about the new simple admin interface. The next version will be able to cover all functionality and improves usability further :-)

Re: How to hide unique products in catalogue when they are s

Posted: 19 Sep 2017, 09:40
by hasmb
Thanks for the info.

We will see which way to go.

One thing to improve usability further would be to make the column selection and sort direction in backend list views persitent. Every time the user leaves the shop interface additionally selected columns are gone - both in expert and simple.

Re: How to hide unique products in catalogue when they are s

Posted: 21 Sep 2017, 09:48
by aimeos
In the dev-master branch usability already has improved including the list view. Stay tuned for the 2017.10 version :-)

Re: How to hide unique products in catalogue when they are s

Posted: 06 Dec 2020, 12:38
by Ahmad
aimeos wrote: 14 Sep 2017, 17:05 The stock level data is loaded async via AJAX.

You have three options:
- Extend the Javascript method that's used to add the stock levels to hide those products
- Extend the catalog lists class where you retrieve the stock levels for the products and remove those that are out of stock
- Write a frontend controller decorator that deactivates the product if it's out of stock

The Javascript approach is very simple to implement. The first two options have the disadvantage that a product listing can contain less products than normal, e.g. 23 products instead of 24 on the first page, 24 on the second and so on. Which do you prefer?

That's good to hear that about the new simple admin interface. The next version will be able to cover all functionality and improves usability further :-)
Hi, I use aimeos/laravel 2020.07 and have the same request

I want to show products with stock-level > 0 by default and just when customer select show products have stock option in filters show all of products.
can you please explain with code:
- how can I "Extend the catalog lists class where you retrieve the stock levels for the products and remove those that are out of stock"
and
- how can I "Write a frontend controller decorator that deactivates the product if it's out of stock"

Of course I know how extent components and controllers, just I want to know:
- how can I filter products with stock-level > 0

Re: How to hide unique products in catalogue when they are sold?

Posted: 07 Dec 2020, 11:02
by aimeos
It's not available in 2020.10 but we've implemented this feature in the dev-master branch now:
- https://github.com/aimeos/aimeos-core/c ... 78bf85eca1
- https://github.com/aimeos/ai-controller ... e918408557
- https://github.com/aimeos/ai-client-htm ... 3377886364

The feature will be part of the 2021.x releases

Re: How to hide unique products in catalogue when they are sold?

Posted: 07 Dec 2020, 14:58
by Ahmad
aimeos wrote: 07 Dec 2020, 11:02 It's not available in 2020.10 but we've implemented this feature in the dev-master branch now:
- https://github.com/aimeos/aimeos-core/c ... 78bf85eca1
- https://github.com/aimeos/ai-controller ... e918408557
- https://github.com/aimeos/ai-client-htm ... 3377886364

The feature will be part of the 2021.x releases
thank you very much for this, but:
- I think you have mistake in https://github.com/aimeos/ai-client-htm ... d849e7R690 and that is we should change f_sort with f_stock
- I get an discoverable exception and check admin log and get this error:

Code: Select all

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'msto.prodid' in 'on clause': 
after that I change this line https://github.com/aimeos/aimeos-core/c ... b73c2f6R29
with

Code: Select all

'internaldeps' => ['LEFT JOIN "mshop_stock" AS msto ON mpro."code" = msto."productcode"'],
and the problem fixed and don't get this error anymore. I do this change because when I check mshop_stock table don't find column named prodid
Is the change I made on this line correct?
Please note that I use 2020.07 not 2020.10, Do I need to upgrade to 2020.10?

Re: How to hide unique products in catalogue when they are sold?

Posted: 08 Dec 2020, 09:35
by aimeos
Ahmad wrote: 07 Dec 2020, 14:58 - I get an discoverable exception and check admin log and get this error:

Code: Select all

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'msto.prodid' in 'on clause': 
after that I change this line https://github.com/aimeos/aimeos-core/c ... b73c2f6R29
with

Code: Select all

'internaldeps' => ['LEFT JOIN "mshop_stock" AS msto ON mpro."code" = msto."productcode"'],
and the problem fixed and don't get this error anymore. I do this change because when I check mshop_stock table don't find column named prodid
Is the change I made on this line correct?
This is due to a different schema for mshop_stock in dev-master than in 2020.10.x. Your change is therefore correct.

Nevertheless, we've decided to revert the changes because it works with MySQL only - not with MariaDB, PostgreSQL and especially not with ElasticSearch and Solr. You can use the code for your own project but it won't be available in 2021.x due to the principle problems which arise with that feature.

Please also note that stock levels are highly volatile and you can't use caching for the catalog/lists component at all.
Ahmad wrote: 07 Dec 2020, 14:58 Please note that I use 2020.07 not 2020.10, Do I need to upgrade to 2020.10?
Yes, 2020.07 isn't supported any more, onle 2020.10 LTS.

Re: How to hide unique products in catalogue when they are sold?

Posted: 10 Dec 2020, 22:24
by Ahmad
aimeos wrote: 08 Dec 2020, 09:35
Ahmad wrote: 07 Dec 2020, 14:58 - I get an discoverable exception and check admin log and get this error:

Code: Select all

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'msto.prodid' in 'on clause': 
after that I change this line https://github.com/aimeos/aimeos-core/c ... b73c2f6R29
with

Code: Select all

'internaldeps' => ['LEFT JOIN "mshop_stock" AS msto ON mpro."code" = msto."productcode"'],
and the problem fixed and don't get this error anymore. I do this change because when I check mshop_stock table don't find column named prodid
Is the change I made on this line correct?
This is due to a different schema for mshop_stock in dev-master than in 2020.10.x. Your change is therefore correct.

Nevertheless, we've decided to revert the changes because it works with MySQL only - not with MariaDB, PostgreSQL and especially not with ElasticSearch and Solr. You can use the code for your own project but it won't be available in 2021.x due to the principle problems which arise with that feature.

Please also note that stock levels are highly volatile and you can't use caching for the catalog/lists component at all.
Ahmad wrote: 07 Dec 2020, 14:58 Please note that I use 2020.07 not 2020.10, Do I need to upgrade to 2020.10?
Yes, 2020.07 isn't supported any more, onle 2020.10 LTS.
thanks a lot for your answers, I still have 2 problem with this:
- I change your code in the Controller/Frontend/Product/Standard.php file for own customize such a way that all of requests get products with stocklevel > 0, but the product counter in catalog/filter still include products with zero stocklevel, for example i have 2 products in category 1 which is one of them have stock level > 0 and another have stock level = 0, with my change when user is in the category 1 just see product with stock level > 0 in the list, but still in the catalog/filter shows there is 2 product in the category 1, how can I change to just show count of products with stock level > 0 in the catalog/filter?

- based on the above description, how can I remove products with stock level = 0 from catalog/filter search suggestions so that when user is typing just show (suggest) products with stock level > 0 in the s

Re: How to hide unique products in catalogue when they are sold?

Posted: 11 Dec 2020, 12:03
by aimeos
For the Attribute, Supplier and Tree subpart (https://github.com/aimeos/ai-client-htm ... alog/Count), create own implementations and add this condition, e.g. here:
https://github.com/aimeos/ai-client-htm ... d.php#L252

Code: Select all

->compare( '>', 'stock.stocklevel', 0 )
https://github.com/aimeos/ai-controller ... hp#L53-L62