Add suggestion Product to basket directly

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
merzilla
Posts: 6
Joined: 17 Apr 2018, 09:52

Add suggestion Product to basket directly

Post by merzilla » 17 Apr 2018, 10:06

We have extended our basket with the "suggestion" partial from product detail view. The suggestion products are rendered as list with link to detail.
Now we want to extend the suggestion products (type=select) to be able to put them directly into the basket. So I thought taking the from from `client/html/templates/catalog/detail/body-standard.php` would do the trick.
The products are the variants of the (parent) select-product, let's say 13,14 and 15. If I want to add it to the basket, the basket gets loaded with an message "Product with ID 13 is not allowed to be added directly to the basket".
On the detail page of the select-product, I can add ID 13, however.
Has anybody a hint how to achieve this?

Thx in advance.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Add suggestion Product to basket directly

Post by aimeos » 18 Apr 2018, 07:46

Catalog/Lists is a good example for this because it does the same you want to achive and you can reuse the product list partial without changes. The most important parts are:
- Get product variants: https://github.com/aimeos/ai-client-htm ... d.php#L308
- The domains for the parent products must be the same as here: https://github.com/aimeos/ai-client-htm ... d.php#L310
- Pass them to the partial rendering the product list: https://github.com/aimeos/ai-client-htm ... rd.php#L41
- basket-add passed to the partial must be true (can be constant): https://github.com/aimeos/ai-client-htm ... rd.php#L40
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

merzilla
Posts: 6
Joined: 17 Apr 2018, 09:52

Re: Add suggestion Product to basket directly

Post by merzilla » 18 Apr 2018, 09:33

Thank you very much for the help! This makes it clearer and I now get the "add to basket" buttons :) Great!
One more thing:
Can I configure the variant products to not "must have" a category assigned? As I understood the system: I create a "select" article, then add variants there. After that I add the prices and stock values in each variant article itself.
In another normal product, I add these variants as suggestion products. But I must set at least one category in the variants to be able to put them into the basket, because `addProduct()` checks if a product has `category.list.type`set to "something". Right?
Thank you very much!

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Add suggestion Product to basket directly

Post by aimeos » 19 Apr 2018, 07:32

You should add the selection as suggested product, not the article itself. If you link to a single variant article, it must be in a category so the basket will accept it.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

merzilla
Posts: 6
Joined: 17 Apr 2018, 09:52

Re: Add suggestion Product to basket directly

Post by merzilla » 15 Jun 2018, 14:27

I just wanted to say thank you, dude :)
Adding to basket works now for me, too.

Post Reply