Get the list of properties in media
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!
- AmzoooJibal
- Posts: 35
- Joined: 12 Mar 2021, 20:09
Get the list of properties in media
Hello,
i need to get the list of properties in media domaine inside advanced section in catalog.
I have a catalog with list of media for the catalog i can do:
Then to get the media:
Now for each mediaItem how i can get the config properties ?
i need to get the list of properties in media domaine inside advanced section in catalog.
I have a catalog with list of media for the catalog i can do:
Code: Select all
$homeTree->getConfig()
Code: Select all
($mediaItems = $this->homeTree->getRefItems('media', 'stage', 'default'))->isEmpty())
- AmzoooJibal
- Posts: 35
- Joined: 12 Mar 2021, 20:09
Re: Get the list of properties in media
Is Like this:
Code: Select all
$this->homeTree->getListItem('media','default',$mediaItem->getId())->getConfig();
Re: Get the list of properties in media
Media items doesn't have a configuration but you can attach property items to them (type, language, value pairs) in the admin backend. Then, you can get them using:
Code: Select all
foreach($this->homeTree->getRefItems('media','default') as $mediaItem) {
print_r($mediaItem->getProperties('<type of the property>'));
}
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
- AmzoooJibal
- Posts: 35
- Joined: 12 Mar 2021, 20:09
Re: Get the list of properties in media
Thank you for you response.
It's a little complicated aimeos object.
With laravel Eloquent its easy to get child from parent even if the relation isnt loaded initially.
my question in home page i have a product object (Aimeos\MShop\Product\Item\Standard) and i need to access the variant product from this object how i can do that ?
i have tried but list empty:
It's a little complicated aimeos object.
With laravel Eloquent its easy to get child from parent even if the relation isnt loaded initially.
my question in home page i have a product object (Aimeos\MShop\Product\Item\Standard) and i need to access the variant product from this object how i can do that ?
i have tried but list empty:
Code: Select all
$product->getRefItems('attribute', null, 'variant')
Re: Get the list of properties in media
That's one of the reasons we don't use Eloquent or something that offers that feature because this will load the related records on request. This turns into a performance nightmare if it's actually used because e.g. for a product list view with 100 products, 201 queries will be executed (one for all products, 100 for the relations and 100 for the attribute records) and people are complaining why it's so slow.AmzoooJibal wrote: ↑27 Apr 2021, 17:00 It's a little complicated aimeos object.
With laravel Eloquent its easy to get child from parent even if the relation isnt loaded initially.
Contrary, in Aimeos you need to say upfront what should be loaded so there will be only three queries executed (one for the product, one for the relation and one for the attribute records).
Your code is correct but you need to configure that the product attributes should be loaded in the catalog/home component:AmzoooJibal wrote: ↑27 Apr 2021, 17:00 my question in home page i have a product object (Aimeos\MShop\Product\Item\Standard) and i need to access the variant product from this object how i can do that ?
i have tried but list empty:
Code: Select all
$product->getRefItems('attribute', null, 'variant')
https://aimeos.org/docs/latest/config/c ... e/#domains
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