How to get product attribute type name

Help for integrating the Laravel package
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!
awaidqureshi
Posts: 86
Joined: 12 Jan 2019, 15:17

How to get product attribute type name

Post by awaidqureshi » 02 Oct 2019, 13:02

How to get product attribute type name like i want to get media item type name (standard ,Or custom that i made)

Please guide me about this

Thanks

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

Re: How to get product attribute type name

Post by aimeos » 03 Oct 2019, 09:27

The attribute type label isn't part of all attribute items any more. You have to retrieve the type items yourself using something like this:

Code: Select all

$manager = \Aimeos\MShop::create( $context, 'attribute/type' );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'attribute.type.code', [<codes>] ) );

foreach( $manager->searchItems( $search ) as $typeItem ) {
	$label = $typeItem->getLabel();
}
But for translations, this is a bad choice, you should use the type codes from the attriubte items instead and pass them in the view to:

Code: Select all

$this->translate( 'client/code', $typecode );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

awaidqureshi
Posts: 86
Joined: 12 Jan 2019, 15:17

Re: How to get product attribute type name

Post by awaidqureshi » 04 Oct 2019, 06:51

aimeos wrote: 03 Oct 2019, 09:27 The attribute type label isn't part of all attribute items any more. You have to retrieve the type items yourself using something like this:

Code: Select all

$manager = \Aimeos\MShop::create( $context, 'attribute/type' );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'attribute.type.code', [<codes>] ) );

foreach( $manager->searchItems( $search ) as $typeItem ) {
	$label = $typeItem->getLabel();
}
But for translations, this is a bad choice, you should use the type codes from the attriubte items instead and pass them in the view to:

Code: Select all

$this->translate( 'client/code', $typecode );
Screenshot_5.png
Screenshot_5.png (24.52 KiB) Viewed 1603 times
when i get the product media with this
$this->detailProductItem->getRefItems('media');

This data i am getting of media item
the type value become default.

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

Re: How to get product attribute type name

Post by aimeos » 04 Oct 2019, 08:21

The type code is part of all items that has a type column but not the type label.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply