Retrieve all media of all selection products of product

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Icymars
Posts: 12
Joined: 16 Dec 2020, 18:33

Retrieve all media of all selection products of product

Post by Icymars » 24 Jan 2021, 17:34

Hi guys, I need help and hope one of you can do it.
I need to get all images related to a product of select type. Which command can do it?
In code of body-standard.php in detail folder the media elements were getting with that :
$this->get( 'detailMediaItems', map() )
but if i use in products-standard.php it return: Aimeos\Map Object ( [list:protected] => Array ( ) ) 1

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

Re: Retrieve all media of all selection products of product

Post by aimeos » 25 Jan 2021, 09:00

The media items for the detailMediaItems property are created here:
https://github.com/aimeos/ai-client-htm ... #L547-L554

You have to pass

Code: Select all

'detailMediaItems' => $this->get( 'detailMediaItems', map() )
to the partial to get that data in the partial too:
e.g. here: https://github.com/aimeos/ai-client-htm ... d.php#L525
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Icymars
Posts: 12
Joined: 16 Dec 2020, 18:33

Re: Retrieve all media of all selection products of product

Post by Icymars » 25 Jan 2021, 10:40

So if I want to get images in product-standard.php, I've add

Code: Select all

'detailMediaItems' => $this->get( 'detailMediaItems', map() ),
in items-body-standard.php, in catalog->list folder like this:

Code: Select all

<div class="catalog-list-items" data-infinite-url="<?= $infiniteScroll && $this->get( 'listPageNext', 0 ) > $this->get( 'listPageCurr', 0 ) ? $this->url( $listTarget, $listController, $listAction, array( 'l_page' => $this->get( 'listPageNext' ) ) + $this->get( 'listParams', [] ), [], $listConfig ) : '' ?>">

	<?= $this->partial(
		$this->config( 'client/html/common/partials/products', 'common/partials/products-standard' ),
		array(
			'require-stock' => (int) $this->config( 'client/html/basket/require-stock', true ),
			//'basket-add' => $this->config( 'client/html/catalog/lists/basket-add', true ),
			'productItems' => $this->get( 'itemsProductItems', map() ),
			'products' => $this->get( 'listProductItems', map() ),
			'position' => $this->get( 'itemPosition' ),
			'detailMediaItems' => $this->get( 'detailMediaItems', map() ),
		)
	); ?>

</div>
and then retrieve the value from product-standard.php like this:

Code: Select all

$this->get('detailMediaItems', [])
right?

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

Re: Retrieve all media of all selection products of product

Post by aimeos » 26 Jan 2021, 08:03

In the catalog/lists panel, the "detailMediaItems" view property isn't available. You can either create a decorator to add "listMediaItems" based on the code from the link or you add that code in the template to create it there.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply