How to get attribute's option on frontend
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 get attribute's option on frontend
Could you give me an idea how can I get an attribute's option (see screenshot) on frontend?
I'd like to get the "colorcode" option for each color product attribute on frontend.
In user manual there is
"Option/Value (optional)
Arbitrary list of key/value pairs that will be available with each image/media item in the frontend"
But how?
I'd like to get the "colorcode" option for each color product attribute on frontend.
In user manual there is
"Option/Value (optional)
Arbitrary list of key/value pairs that will be available with each image/media item in the frontend"
But how?
- Attachments
-
- Screenshot_39.jpg (43.35 KiB) Viewed 1459 times
Re: How to get attribute's option on frontend
For example, you can get the value here:
https://github.com/aimeos/ai-client-htm ... d.php#L375
using:
If you use a media property instead, you can also use it in the partial rendering the icons:
https://github.com/aimeos/ai-client-htm ... hp#L52-L57
by using:
https://github.com/aimeos/ai-client-htm ... d.php#L375
using:
Code: Select all
$listItem->getConfigValue( 'colorcode' )
https://github.com/aimeos/ai-client-htm ... hp#L52-L57
by using:
Code: Select all
$item->getProperties( 'colorcode' )->first()
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: How to get attribute's option on frontend
I'm wondering if the OP resolved the issue. I'm dealing with the same trouble, where catalog item has an image. while i'm setting options to the image i'm not able to retrieve that option.
Aimeos\MShop\Media\Item\Standard {#2132 ▼
-langid: "en"
-prefix: "media."
-available: true
-modified: false
#bdata: array:14 [▶]
-listItems: []
-listRefItems: []
-listRmItems: []
-listPrepared: true
-listRmMap: []
-listMap: []
-listMax: 0
-propItems: []
-propRmItems: []
-propMax: 0
}
$image->getProperties('imageopt') returns an empty map, despite the option is set for the media
Aimeos\MShop\Media\Item\Standard {#2132 ▼
-langid: "en"
-prefix: "media."
-available: true
-modified: false
#bdata: array:14 [▶]
-listItems: []
-listRefItems: []
-listRmItems: []
-listPrepared: true
-listRmMap: []
-listMap: []
-listMax: 0
-propItems: []
-propRmItems: []
-propMax: 0
}
$image->getProperties('imageopt') returns an empty map, despite the option is set for the media
Re: How to get attribute's option on frontend
The option/value pairs are not stored as properties but in "bdata[media.config]" of the item instead. You can get the value using:
Code: Select all
$mediaItem->getConfigValue( 'colorcode' );
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