Access product properties in basket

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!
mainfactory
Posts: 6
Joined: 06 Dec 2018, 12:33

Access product properties in basket

Post by mainfactory » 10 Dec 2018, 15:03

Dear aimeos Team

How can I access product properties inside the basket view?
As I can see the properties values are not available inside the array the $this->summaryBasket->getProducts() is returning
in the file /html/templates/common/summary/detail-standard.php

Or as an alternative is it easier to access a «Article specific configuration options» (Setup at the basic tab of a product / key/value pair ) inside the basket?

I just need a value that I can use specific for every product inside the basket (and also on the product detail page).

I'm using Typo3 8.7.20 with aimeos 18.10.2 / PHP 7.2.1 / Apache (Local on Mac OS with MAMP).

Thank you!

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

Re: Access product properties in basket

Post by aimeos » 10 Dec 2018, 19:48

If you only need a single, specific property, you can add it to the basket product by configuring the "PropertyAdd" basket plugin: https://github.com/aimeos/aimeos-core/b ... dd.php#L16
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mainfactory
Posts: 6
Joined: 06 Dec 2018, 12:33

Re: Access product properties in basket

Post by mainfactory » 11 Dec 2018, 08:02

Thank you for your fast support!
Can you please tell me more about how I can configure the PropertyAdd basket plugin...
As I can see the file PropertyAdd.php is already part of your aimeos core. At the top of the file I can see the example configuration. Where do I have to add this configuration - by TypoScript Setup?

Example configuration:
* - product.property.parentid: ['length', 'width', 'heigth', 'weigth']

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

Re: Access product properties in basket

Post by aimeos » 11 Dec 2018, 11:45

The configuration needs to be added to the config section of the basket plugin in the admin interface
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mainfactory
Posts: 6
Joined: 06 Dec 2018, 12:33

Re: Access product properties in basket

Post by mainfactory » 11 Dec 2018, 13:43

I could set up the PropertyAdd Plugin now. The property I want to add to the basket has the code 'pp-dim-width' in my case. I tried different configurations but no one is working. Depending on my setup I get the following error:

Argument 3 passed to Aimeos\MShop\Plugin\Provider\Order\PropertyAdd::addAttributes() must be of the type array, string given,

Or I just get no error message but I cant see the given value at the basket product object anyway.
To test if I get the value I need inside the basket I just use

Code: Select all

<?php var_dump($product); ?>
at the file detail-standard.php and then search for my pp-dim-width attribute. But I cant see it there.

Can you please tell me how exactly the plugin configuration must look like?

Thank you.
Attachments
aimeos-add-product-property-to-basket.png
aimeos-add-product-property-to-basket.png (68.44 KiB) Viewed 2354 times

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

Re: Access product properties in basket

Post by aimeos » 12 Dec 2018, 09:23

Think, the value must be

Code: Select all

["pp-dim-width"]
as it's interpreted as JSON. Can you try?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mainfactory
Posts: 6
Joined: 06 Dec 2018, 12:33

Re: Access product properties in basket

Post by mainfactory » 07 Jan 2019, 10:37

I tried out different configurations / different strings to pass the value to the basket. But without success. I can not see the value in the product object inside the basket. Some of the JSON-string values I entered directly into the database, because the backend did not accept my values (the save button does not react - without error message).

Now I did a completely other solution with JavaScript and LocalStorage outside aimeos. This is working for me because I don't really need the basket in this project (we dont need the order part on this project - instead we have a favourite / collection-box function). But for a future project, solving this issues here may become important again...

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

Re: Access product properties in basket

Post by aimeos » 07 Jan 2019, 12:23

A rewrite of the plugin is on the list: https://github.com/aimeos/aimeos-core/issues/133
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply